<template>
  <div class="app-container">
    <div>
      <div class="filter-container">
        <el-form :inline="true" class="search-form" label-position="right" label-width="90px">
          <el-row style="display: flex; flex-wrap: wrap">
            <div style="flex: 1">
              <el-form-item label="分组" v-if="searchDisplay" style="margin: 5px 0">
                <el-select clearable v-model="searchForm.group_id" placeholder="请选择分组">
                  <el-option v-for="item in groupList" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="性别" style="margin: 5px 0" v-if="searchDisplay">
                <el-select clearable v-model="searchForm.gender" placeholder="请选择性别">
                  <el-option v-for="item in [
                    { name: '男', id: 1 },
                    { name: '女', id: 2 },
                    { name: '保密', id: 0 },
                  ]" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="等级" style="margin: 5px 0" v-if="searchDisplay">
                <el-select clearable v-model="searchForm.level_id" placeholder="请选择等级">
                  <el-option v-for="item in gradeList" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="是否认证" style="margin: 5px 0">
                <el-select clearable v-model="searchForm.is_real_name" placeholder="请选择认证状态">
                  <el-option v-for="item in [
                    { name: '已认证', id: 1 },
                    { name: '未认证', id: 2 },
                  ]" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="是否消费" style="margin: 5px 0" v-if="searchDisplay">
                <el-select clearable v-model="searchForm.is_consume" placeholder="请选择是否消费">
                  <el-option v-for="item in [
                    { name: '已消费', id: 1 },
                    { name: '未消费', id: 2 },
                  ]" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="用户身份" style="margin: 5px 0" v-if="searchDisplay">
                <el-select clearable v-model="searchForm.identity_type" placeholder="请选择用户身份">
                  <el-option v-for="item in [
                    { name: '普通用户', id: 1 },
                    { name: '推广员', id: 2 },
                  ]" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="用户状态" style="margin: 5px 0" v-if="searchDisplay">
                <el-select clearable v-model="searchForm.status" placeholder="请选择用户状态">
                  <el-option v-for="item in [
                    { name: '已启用', id: 1 },
                    { name: '已冻结', id: 0 },
                  ]" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="是否新用户" style="margin: 5px 0" v-if="searchDisplay">
                <el-select clearable v-model="searchForm.is_new_user" placeholder="请选择是否新用户">
                  <el-option v-for="item in [
                    { name: '新用户', id: 1 },
                    { name: '老用户', id: 2 },
                  ]" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="搜索" style="margin: 5px 0">
                <el-input clearable placeholder="请输入内容" v-model="searchForm.search_name"
                  onkeyup="value =value.replace(/[^a-zA-Z0-9\u4e00-\u9fa5]/g, '')" class="input-with-select">
                  <el-select v-model="searchForm.search_type" slot="prepend" placeholder="类型">
                    <el-option label="全部" :value="1"></el-option>
                    <el-option label="用户ID" :value="2"></el-option>
                    <el-option label="手机号" :value="3"></el-option>
                    <el-option label="昵称" :value="4"></el-option>
                  </el-select>
                </el-input>
              </el-form-item>
            </div>
            <div style="margin: 5px 0; text-align: right">
              <el-form-item>
                <el-button size="small" type="primary" icon="el-icon-search" @click="getListWay">查询</el-button>
                <el-button size="small" type="primary" icon="el-icon-refresh" @click="resetting">重置</el-button>
                <el-button v-if="!searchDisplay" type="warning" icon="el-icon-caret-bottom"
                  @click="searchDisplay = true">展开</el-button>
                <el-button v-else type="warning" icon="el-icon-caret-top" @click="searchDisplay = false">收起</el-button>
              </el-form-item>
            </div>
          </el-row>
        </el-form>
      </div>
    </div>
    <el-divider></el-divider>
    <div class="grouping" style="margin-top: 20px">
      <div class="marginBottom">
        <el-row :gutter="20">
          <el-col :span="20">
            <el-button v-hasPermi="'consumer/add'" type="primary" size="small" @click="addUserWay"
              icon="el-icon-circle-plus-outline">添加用户</el-button>
            <el-button v-hasPermi="'consumer/coupon'" type="warning" size="small" @click="sendCouponsWay"
              icon="el-icon-setting">发送优惠券</el-button>
          </el-col>
          <el-col :span="4" style="float: right">
            <div class="right-panel el-button-group">
              <el-button class="" icon="el-icon-refresh" size="mini" @click="refresh"></el-button>
              <el-dropdown trigger="click" :hide-on-click="false">
                <span class="el-dropdown-link">
                  <el-button class="" icon="el-icon-s-operation" size="mini"></el-button>
                </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item v-for="fruit in allTableThead" :key="fruit">
                    <el-checkbox v-model="checkboxTableThead" :label="fruit">{{
                      tableTheadOptions[fruit].label
                    }}</el-checkbox>
                  </el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </div>
          </el-col>
        </el-row>
      </div>
      <el-row :gutter="20">
        <el-col>
          <el-table highlight-current-row :data="userList" :header-cell-style="{
            'background-color': '#f3f8fe',
            color: '#606266',
            height: '50px',
          }" style="width: 100%" v-loading="loading" @selection-change="handleSelectionChange">
            <el-table-column align="center" type="selection" width="55">
            </el-table-column>
            <!-- <el-table-column align="center" prop="avatar" label="用户头像">
              <template slot-scope="scope">
                <div style="width: 40px; height: 40px; margin: 0 auto">
                  <el-image v-if="scope.row.avatar" :src="scope.row.avatar" :preview-src-list="[scope.row.avatar]" />
                </div>
              </template>
            </el-table-column> -->
            <el-table-column v-for="fruit in tableThead" :key="fruit" :label="tableTheadOptions[fruit].label"
              min-width="80" align="center">
              <template slot-scope="scope">
                <div v-if="fruit == 'avatar'">
                 <div style="width: 40px; height: 40px; margin: 0 auto">
                   <el-image v-if="scope.row.avatar" :src="scope.row.avatar" :preview-src-list="[scope.row.avatar]" />
                 </div>
                </div>
                <div v-else>
                  <el-tooltip
                    placement="top-start"
                    :content="scope.row[fruit] + ''"
                  >
                    <div class="one_line_hidden">
                      {{ scope.row[fruit] ? scope.row[fruit] : "-" }}
                    </div>
                  </el-tooltip>
                </div>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="gender" label="用户性别">
              <template slot-scope="scope">
                <div v-if="scope.row.gender == 0" size="mini">保密</div>
                <div v-if="scope.row.gender == 1" size="mini">男</div>
                <div v-if="scope.row.gender == 2" size="mini">女</div>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="is_new" label="是否消费">
              <template slot-scope="scope">
                <span v-if="scope.row.is_consume">是</span>
                <span v-else>否</span>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="is_new" label="用户标签">
              <template slot-scope="scope">
                <span v-if="scope.row.user_tag_arr.length > 0">
                <el-tooltip :content="scope.row.user_tag_arr.join(',')" placement="top">
                  <span v-for="item, inx in scope.row.user_tag_arr" :key="inx">{{ item }}
                  </span>
                </el-tooltip>

                </span>
                <span v-else>-</span>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="is_new" label="用户分组">
              <template slot-scope="scope">
                <el-tooltip
                  placement="top-start"
                  :content="scope.row.group_name + ''"
                >
                  <div class="one_line_hidden">
                    {{ scope.row.group_name ? scope.row.group_name : "-" }}
                  </div>
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="is_new" label="用户区域">
              <template slot-scope="scope">
                <el-tooltip
                  placement="top-start"
                  :content="scope.row.address_name + ''"
                >
                  <div class="one_line_hidden">
                    {{ scope.row.address_name ? scope.row.address_name : "-" }}
                  </div>
                </el-tooltip>

              </template>
            </el-table-column>
            <el-table-column align="center" fixed="right" width="200" prop="address" label="操作">
              <template slot-scope="scope">
                <span v-hasPermi="'consumer/freeze'">
                  <el-button v-if="scope.row.status == 1" type="warning" size="mini" @click="freezeWay(scope.row)">
                    冻结
                  </el-button>
                  <el-button v-else type="success" size="mini" @click="thawWay(scope.row)">
                    重新启用
                  </el-button>
                </span>
                <el-button style="margin-left: 10px" type="primary" size="mini" @click="drawerHandle(scope.row)">
                  详情
                </el-button>
                <el-popconfirm title="确定要删除该用户吗？" @confirm="deleteCoupon(scope.row)">
                  <el-button v-hasPermi="'consumer/del'" style="margin-left: 10px" type="danger" size="mini"
                    slot="reference">
                    删除
                  </el-button>
                </el-popconfirm>
              </template>
            </el-table-column>
          </el-table></el-col>
      </el-row>
      <el-row style="text-align: right">
        <pagination v-show="total > 0" :total="total" :page.sync="searchForm.page" :limit.sync="searchForm.count"
          @pagination="getListWay" />
      </el-row>
    </div>
    <!-- 添加,修改用户弹框 -->
    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="会员等级配置" size="70%" :withHeader="false"
      :visible.sync="userVisible" @close="userHandleClose" :show-close="true">
      <div style="position: relative;margin-bottom: 30px;">
        <div class="drawerTitle">
          <span>基本信息</span>
          <div class="close" @click="userHandleClose">
            <i class="el-icon-close" style="font-size: 24px;"></i>
          </div>
        </div>
      </div>
      <el-scrollbar wrap-style="overflow-x:hidden;" style="height: calc(100vh - 185px)">
        <el-form :model="ruleForm" label-position="right" status-icon :rules="rules" ref="ruleForm" label-width="110px"
          class="demo-ruleForm">
          <el-row style="display: flex; flex-wrap: wrap">
            <el-col :span="11">
              <el-form-item label="昵称" prop="nickname">
                <el-input :compositionend="true" type="text" maxlength="10" clearable show-word-limit
                  placeholder="请输入用户昵称" v-model="ruleForm.nickname"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="手机号" prop="mobile">
                <el-input onkeyup="value=value.replace(/\D/g,'')" placeholder="请输入手机号" maxlength="11"
                  v-model="ruleForm.mobile" show-word-limit></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="用户头像" prop="avatar">
                <logo-upload :single-file="avatarFile" :show-file-list="false" accept="image/jpeg, image/png"
                  @uploadCallback="avatarCallback" />
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="生日" prop="birthday">
                <el-date-picker @change="birthdayWay" value-format="yyyy-MM-dd" v-model="ruleForm.birthday" type="date"
                  placeholder="选择生日">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="年龄" prop="age">
                <el-input type="text" :maxlength="3" onkeyup="value=value.replace(/\D/g,'')" placeholder="请选择生日(自动计算)"
                  v-model="ruleForm.age"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="省份" prop="province_id">
                <el-select clearable v-model="ruleForm.province_id" @change="provinceWay" placeholder="请选择省份">
                  <el-option v-for="item in economizeList" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="城市" prop="city_id">
                <el-select clearable v-model="ruleForm.city_id" @change="cityWay" placeholder="请选择城市">
                  <el-option v-for="item in cityList" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="区/县" prop="county_id">
                <el-select clearable v-model="ruleForm.county_id" @change="countyWay" placeholder="请选择区/县">
                  <el-option v-for="item in countyList" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="22">
              <el-form-item label="详细地址" prop="region">
                <el-input type="text" placeholder="请输入详细地址" v-model="ruleForm.region"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="性别" prop="gender">
                <el-radio v-model="ruleForm.gender" label="1">男</el-radio>
                <el-radio v-model="ruleForm.gender" label="2">女</el-radio>
                <el-radio v-model="ruleForm.gender" label="0">保密</el-radio>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="邮箱" prop="email">
                <el-input type="text" onkeyup="value=value.replace(/[\u4E00-\u9FA5]/g,'')" placeholder="请输入邮箱"
                  v-model="ruleForm.email"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="登录密码" prop="password">
                <el-input type="password" :show-password="true" :maxlength="16" :minlength="8"
                  onkeyup="value=value.replace(/[\u4E00-\u9FA5]/g,'')" placeholder="请输入登录密码"
                  v-model.trim="ruleForm.password"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="确认密码" prop="confirm_password">
                <el-input type="password" :show-password="true" :maxlength="16" :minlength="8"
                  onkeyup="value=value.replace(/[\u4E00-\u9FA5]/g,'')" placeholder="请再次输入登录密码"
                  v-model.trim="ruleForm.confirm_password"></el-input>
              </el-form-item>
            </el-col>
            <!-- <el-col :span="11">
            <el-form-item label="支付密码" prop="pay_password">
              <el-input
                type="password"
                onkeyup="value=value.replace(/\D/g,'')"
                :maxlength="6"
                :minlength="6"
                :show-password="true"
                placeholder="请输入支付密码"
                v-model.trim="ruleForm.pay_password"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="确认支付密码" prop="confirm_pay_password">
              <el-input
                type="password"
                onkeyup="value=value.replace(/\D/g,'')"
                :maxlength="6"
                :minlength="6"
                :show-password="true"
                placeholder="请再次输入支付密码"
                v-model.trim="ruleForm.confirm_pay_password"
              ></el-input>
            </el-form-item>
          </el-col> -->
            <el-col :span="11">
              <el-form-item label="用户等级" prop="level_id">
                <el-select v-model="ruleForm.level_id" placeholder="请选择等级">
                  <el-option v-for="item in gradeList" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="用户分组" prop="group_id">
                <el-select v-model="ruleForm.group_id" placeholder="请选择分组">
                  <el-option v-for="item in groupList" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="22">
              <el-form-item label="用户标签" prop="user_tag_id">
                <el-select @change="ruleFormUsertagid" style="width: 100%" v-model="user_tag_id" multiple
                  placeholder="请选择标签">
                  <el-option-group v-for="group in TagCategoryAll" :key="group.category_name"
                    :label="group.category_name">
                    <el-option v-for="item in group.child" :key="item.id" :label="item.tag_name" :value="item.id">
                    </el-option>
                  </el-option-group>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="用户状态" prop="status">
                <el-radio v-model="ruleForm.status" :label="1">启用</el-radio>
                <el-radio v-model="ruleForm.status" :label="0">禁用</el-radio>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-scrollbar>
      <el-col :span="24" style="text-align: right;padding-right:30px">
        <el-button @click="userVisible = false">取消</el-button>
        <el-button :loading="addPutLoading" type="primary" @click="submitForm('ruleForm')">保存</el-button>
      </el-col>
    </el-drawer>
    <!-- 详情 -->
    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="用户详情" size="70%" :withHeader="false"
      :visible.sync="drawer" @close="drawerHandleClose" :show-close="true">
      <div class="drawerTitle">
        <span>用户详情</span>
        <div class="close" @click="drawerHandleClose">
          <i class="el-icon-close" style="font-size: 24px;"></i>
        </div>
      </div>
      <el-scrollbar wrap-style="overflow-x:hidden;" style="height: calc(100vh - 120px)">
        <div style="padding: 10px 30px">
          <div class="infoDivTop">
          </div>
          <div class="infoDiv" style="">
            <div class="img" style="overflow: hidden">
              <el-image style="width: 100%; height: 100%" :src="userInfoForm.avatar" fit="cover"></el-image>
            </div>
            <div class="scenter">
              <div class="order_center">
                <div>
                  <div class="orderdetail_item">
                    <p>用户昵称：</p>
                    <p>
                      {{
                      userInfoForm.nickname
                      ? userInfoForm.nickname
                      : "--"
                    }}
                    </p>
                  </div>
                  <div class="orderdetail_item">
                    <p>用户区域：</p>
                    <p>
                      {{
                      userInfoForm.province_name
                      ? userInfoForm.province_name + userInfoForm.city_name
                      : "--"
                    }}
                    </p>
                  </div>
                </div>
                <div>
                  <div class="orderdetail_item">
                    <p>可用余额：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.available_balance
                      : "0.00"
                    }}
                    </p>
                  </div>
                  <div class="orderdetail_item">
                    <p>冻结余额：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.locked_balance
                      : "0.00"
                    }}
                    </p>
                  </div>
                </div>
                <div>
                  <div class="orderdetail_item">
                    <p>可用积分：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.available_points
                      : "0.00"
                    }}
                    </p>
                  </div>
                  <div class="orderdetail_item">
                    <p>冻结积分：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.locked_points
                      : "0.00"
                    }}
                    </p>
                  </div>
                </div>
                <div>
                  <div class="orderdetail_item">
                    <p>可用提货券：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.available_coupons
                      : "0.00"
                    }}
                    </p>
                  </div>
                  <div class="orderdetail_item">
                    <p>冻结提货券：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.locked_coupons
                      : "0.00"
                    }}
                    </p>
                  </div>
                </div>
              </div>
            </div>
            <!--  -->
            <div class="right">
              <div class="order_center">
                <div class="orderdetail_item">
                  <p>实名状态：</p>
                  <p style="color:#567722;font-weight: 550;">
                    {{
                    userInfoForm.is_real_auth == 1
                    ? '已实名'
                    : "未实名"
                  }}
                  </p>
                </div>
              </div>
            </div>
          </div>
          <el-tabs v-model="activeNames" @tab-click="infotabshandleClick">
            <el-tab-pane label="基本信息" name="基本信息">
            </el-tab-pane>
            <el-tab-pane label="实名信息" name="实名信息">
            </el-tab-pane>
            <el-tab-pane label="邀请关系" name="邀请关系">
            </el-tab-pane>
            <el-tab-pane label="财产信息" name="财产信息">
            </el-tab-pane>
            <el-tab-pane label="使用设备列表" name="使用设备列表">
            </el-tab-pane>
          </el-tabs>
          <div v-if="activeNames == '使用设备列表'">
            <deviceLists ref="refInventory"></deviceLists>
          </div>
          <div v-if="activeNames == '财产信息'">
            <el-form :model="userInfoForm" status-icon :rules="inforules" ref="inforules" label-width="100px"
              class="demo-ruleForm">
              <el-row :gutter="20">
                <el-col :span="6">
                  <div class="balance_information" @click="balance_details">
                    <div class="banlance">余额</div>
                    <div class="total" v-if="userInfoForm.wallet">{{ userInfoForm.wallet.balance_summary }} <span
                        class="num"></span></div>
                  </div>
                </el-col>
                <el-col :span="6">
                  <div class="balance_information point" @click="integral_details">
                    <div class="banlance">积分</div>
                    <div class="total" v-if="userInfoForm.wallet">{{ userInfoForm.wallet.points_summary }} <span
                        class="num"></span></div>
                  </div>
                </el-col>
                <el-col :span="6">
                  <div class="balance_information vouber" @click="delivery_voucher_details">
                    <div class="banlance">提货券</div>
                    <div class="total" v-if="userInfoForm.wallet">{{ userInfoForm.wallet.coupon_summary }} <span
                        class="num"></span></div>
                  </div>
                </el-col>
                <el-col :span="6">
                  <div class="balance_information coupons" @click="coupons_details">
                    <div class="banlance">卡券</div>
                    <div class="total" v-if="userInfoForm.user_behavior_count">
                      {{userInfoForm.user_behavior_count.coupon_count ? userInfoForm.user_behavior_count.coupon_count :'0'}}<span
                        class="num">张</span></div>
                  </div>
                </el-col>
                <el-col :span="24">
                  <div class="accumulated_consumption">
                    <div class="banlance">其他资产</div>
                    <div class="flexas">
                      <div class="cash_consumption">
                        <div class="cashimg">
                          <i class="el-icon-coin"></i>
                        </div>
                        <div style="height:50px;">
                          <div class="accumulated_price">会员卡</div>
                          <div class="nums" v-if="userInfoForm.user_property">{{userInfoForm.user_property.card_count}}张
                          </div>
                        </div>
                      </div>
                      <div class="cash_consumption">
                        <div class="cashimg"><i class="el-icon-coin"></i></div>
                        <div style="height:50px;">
                          <div class="accumulated_price">通用抽奖次数</div>
                          <div class="nums" v-if="userInfoForm.user_property">
                            {{userInfoForm.user_property.award_count}}次
                          </div>
                        </div>
                      </div>
                      <div class="cash_consumption">
                        <div class="cashimg"><i class="el-icon-coin"></i></div>
                        <div style="height:50px;">
                          <div class="accumulated_price">积分转化卡</div>
                          <div class="nums" v-if="userInfoForm.user_property">
                            {{userInfoForm.user_property.point_conversion_card_count}}张
                          </div>
                        </div>
                      </div>
                      <div class="cash_consumption">
                        <div class="cashimg"><i class="el-icon-coin"></i></div>
                        <div style="height:50px;">
                          <div class="accumulated_price">活动进场券</div>
                          <div class="nums">0张</div>
                        </div>
                      </div>
                    </div>
                  </div>
                </el-col>
                <el-col :span="24">
                  <div class="accumulated_consumption">
                    <div class="banlance">累计消费</div>
                    <div class="flexas">
                      <div class="cash_consumption">
                        <div class="cashimg"><i class="el-icon-coin"></i></div>
                        <div style="height:50px;">
                          <div class="accumulated_price">现消费</div>
                          <div class="nums" v-if="userInfoForm.user_behavior_count">
                            {{userInfoForm.user_behavior_count.balance_record}}
                          </div>
                        </div>
                      </div>
                      <div class="cash_consumption">
                        <div class="cashimg"><i class="el-icon-coin"></i></div>
                        <div style="height:50px;">
                          <div class="accumulated_price">积分消费</div>
                          <div class="nums" v-if="userInfoForm.user_behavior_count">
                            {{userInfoForm.user_behavior_count.integral_record}}
                          </div>
                        </div>
                      </div>
                      <div class="cash_consumption">
                        <div class="cashimg"><i class="el-icon-coin"></i></div>
                        <div style="height:50px;">
                          <div class="accumulated_price">提货券消费</div>
                          <div class="nums" v-if="userInfoForm.user_behavior_count">
                            {{userInfoForm.user_behavior_count.voucher_record}}
                          </div>
                        </div>
                      </div>
                      <div class="cash_consumption">
                        <div class="cashimg"><i class="el-icon-coin"></i></div>
                        <div style="height:50px;">
                          <div class="accumulated_price">总优惠</div>
                          <div class="nums" v-if="userInfoForm.user_behavior_count">
                            {{userInfoForm.user_behavior_count.discount_total}}
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </el-col>
              </el-row>
            </el-form>
          </div>
          <div v-if="activeNames == '邀请关系'" v-loading="subLoading">
            <el-form :model="userInfoForm" status-icon :rules="inforules" ref="inforules" label-width="100px"
              class="demo-ruleForm">
              <el-row :gutter="10" style="display: flex; flex-wrap: wrap">
                <el-col :span="24" class="marginBottom">
                  <div class="blockquote-box" style="display:flex;justify-content:space-between">
                    <span style="flex:1">邀请人信息</span>
                    <!-- <span class="change_record">变更记录 <i class="el-icon-time"></i></span> -->

                  </div>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="用户ID:">
                    <span v-if="userInfoForm.user_invitation_info">{{
                    userInfoForm.user_invitation_info.invitation_user_id ? userInfoForm.user_invitation_info.invitation_user_id : '-'
                  }}</span>
                    <span v-else>-</span>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="用户昵称:">
                    <span v-if="userInfoForm.user_invitation_info">{{
                    userInfoForm.user_invitation_info.nickname ? userInfoForm.user_invitation_info.nickname : '-'
                  }}</span>
                    <span v-else>-</span>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="邀请方式:">
                    <span
                      v-if="userInfoForm.user_invitation_info && userInfoForm.user_invitation_info.nickname">二维码</span>
                    <span v-else>-</span>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="邀请时间:">
                    <span v-if="userInfoForm.user_invitation_info">{{
                    userInfoForm.user_invitation_info.join_date ? userInfoForm.user_invitation_info.join_date : '-'
                  }}</span>
                    <span v-else>-</span>
                  </el-form-item>
                </el-col>
                <!-- <el-col :span="24" class="marginBottom">
                  <div class="blockquote-box" style="display:flex;justify-content:space-between">
                    <span style="flex:1">邀请人关系链</span>
                  </div>
                </el-col> -->
              </el-row>
            </el-form>
          </div>
          <div v-if="activeNames == '实名信息'" v-loading="subLoading">
            <el-form :model="userInfoForm" status-icon :rules="inforules" ref="inforules" label-width="100px"
              class="demo-ruleForm">

              <el-row :gutter="10" style="display: flex; flex-wrap: wrap" v-if="userInfoForm.is_real_auth == 1">
                <el-col :span="24" class="marginBottom">
                  <div class="blockquote-box" style="display:flex;justify-content:space-between">
                    <span style="flex:1">实名信息</span>
                    <span class="realname" v-if="userInfoForm.is_real_auth == 1">已实名</span>
                    <span style="margin-right:20px;font-weight:550;font-size:12px" v-else>未实名</span>
                    <!-- <span class="change_record" @click="change_record">变更记录 <i class="el-icon-time"></i></span> -->

                  </div>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="实名姓名:">
                    <span v-if="userInfoForm.real_name_info">{{
                    userInfoForm.real_name_info.name
                  }}</span>
                    <span v-else>-</span>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="证件类型:">
                    <span>身份证</span>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="证件号:">
                    <span v-if="userInfoForm.real_name_info">{{
                    userInfoForm.real_name_info.id_card_no ? userInfoForm.real_name_info.id_card_no : "-"
                  }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="创建时间:">
                    <span v-if="userInfoForm.real_name_info">{{
                    userInfoForm.real_name_info.created_at
                  }}</span>
                    <span v-else>-</span>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="联系方式:">
                    <span>{{
                    userInfoForm.mobile ? userInfoForm.mobile : "-"
                  }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="联系地址:">
                    <span v-if="userInfoForm.real_name_info">{{
                    userInfoForm.real_name_info.residence_address ? userInfoForm.real_name_info.residence_address : "-"
                  }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="身份证正:">
                    <div v-if="userInfoForm.real_name_info" style="overflow: hidden;width:150px;height:80px;">
                      <el-image style="width: 100%; height: 100%" :src="userInfoForm.real_name_info.id_card_front_photo"
                        fit="cover"></el-image>
                    </div>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="身份证反:">
                    <div v-if="userInfoForm.real_name_info" style="overflow: hidden;width:150px;height:80px;">
                      <el-image style="width: 100%; height: 100%" :src="userInfoForm.real_name_info.id_card_back_photo"
                        fit="cover"></el-image>
                    </div>
                  </el-form-item>
                </el-col>
                <el-col :span="24" class="marginBottom">
                  <div class="blockquote-box" style="display:flex;justify-content:space-between">
                    <span style="flex:1">审核信息</span>
                    <!-- <span class="change_record" @click="audit_records">审核记录 <i class="el-icon-time"></i></span> -->

                  </div>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="审核类型:" prop="">
                    <div>
                      <el-radio disabled v-model="audit_type" label="1">人工</el-radio>
                      <el-radio v-model="audit_type" label="2">系统</el-radio>

                    </div>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="审核时间:">
                    <span v-if="userInfoForm.real_name_info">{{
                    userInfoForm.real_name_info.created_at
                  }}</span>
                    <span v-else>-</span>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="审核人员:">
                    <span v-if="userInfoForm.real_name_info" style="color:#629eff">
                      系统
                    </span>
                    <span v-else>-</span>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="审核说明:">
                    <div style="width:300px;height:80px;background:#f7f8fa;border-radius:6px;padding:0 10px;">--</div>
                  </el-form-item>
                </el-col>
              </el-row>
              <!--  -->
              <el-row v-else>
              <el-col :span="24" class="marginBottom">
                <div class="blockquote-box" style="display:flex;justify-content:space-between">
                  <span style="flex:1">实名信息</span>
                  <span class="realname" v-if="userInfoForm.is_real_auth == 1">已实名</span>
                  <span style="margin-right:20px;font-weight:550;font-size:12px" v-else>未实名</span>
                  <!-- <span class="change_record" @click="change_record">变更记录 <i class="el-icon-time"></i></span> -->

                </div>
              </el-col>
              </el-row>
            </el-form>
          </div>


          <div v-if="activeNames == '基本信息'" v-loading="subLoading">
            <el-form :model="userInfoForm" status-icon :rules="inforules" ref="inforules" label-width="100px"
              class="demo-ruleForm">
              <el-row :gutter="10" style="display: flex; flex-wrap: wrap">
                <el-col :span="24" class="marginBottom">
                  <div class="blockquote-box">账户信息</div>
                </el-col>
                <el-col :span="!editingStatus ? 10 : 10">
                  <el-form-item label="用户头像:">
                    <div style="overflow: hidden;width:72px;height:72px;border-radius:50%">
                      <el-image style="width: 100%; height: 100%" :src="userInfoForm.avatar" fit="cover"></el-image>
                    </div>
                  </el-form-item>
                </el-col>
                <el-col :span="!editingStatus ? 10 : 10">
                  <el-form-item label="账户昵称:" prop="nickname">
                    <span v-if="!editingStatus" style="color:#629eff;font-weight: 550;text-decoration:underline;">{{
                    userInfoForm.nickname
                  }}</span>
                    <el-input v-else type="text" :maxlength="10"
                      onkeyup="value =value.replace(/[^a-zA-Z\u4e00-\u9fa5]/g, '')"
                      v-model="userInfoForm.nickname"></el-input>
                  </el-form-item>
                  <el-form-item label="登录账户:">
                    <span style="color:#629eff;font-weight: 550;text-decoration:underline;">{{
                    userInfoForm.mobile
                  }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="!editingStatus ? 10 : 10">
                  <el-form-item label="用户性别:" prop="gender">
                    <span v-if="!editingStatus">{{
                    userInfoForm.gender == 1
                      ? "男"
                      : userInfoForm.gender == 2
                      ? "女"
                      : "保密"
                  }}</span>
                    <div v-else>
                      <el-radio v-model="userInfoForm.gender" label="1">男</el-radio>
                      <el-radio v-model="userInfoForm.gender" label="2">女</el-radio>
                      <el-radio v-model="userInfoForm.gender" label="0">保密</el-radio>
                    </div>
                  </el-form-item>
                </el-col>
                <el-col :span="!editingStatus ? 10 : 10">
                  <el-form-item label="用户生日:" prop="birthday">
                    <span v-if="!editingStatus">{{
                    userInfoForm.birthday ? userInfoForm.birthday : "-"
                  }}</span>
                    <el-date-picker @change="userInfobirthdayWay" v-else value-format="yyyy-MM-dd"
                      v-model="userInfoForm.birthday" type="date" placeholder="选择日期">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <!-- <el-col :span="!editingStatus ? 10 : 10">
                <el-form-item label="登录账户:">
                  <span style="color:#629eff;font-weight: 550;text-decoration:underline;">{{
                    userInfoForm.mobile
                  }}</span>
                </el-form-item>
              </el-col> -->
                <el-col :span="!editingStatus ? 10 : 10">
                  <el-form-item label="账户等级:" prop="level_id">
                    <span style="color:#629eff;" v-if="!editingStatus">{{
                    userInfoForm.level_name ? userInfoForm.level_name : "-"
                  }}</span>
                    <el-select v-else v-model="userInfoForm.level_id" placeholder="请选择等级">
                      <el-option v-for="item in gradeList" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <!-- <el-col :span="!editingStatus ? 10 : 10">
                <el-form-item label="用户状态:" prop="status">
                  <span v-if="!editingStatus">{{
                    userInfoForm.status == 1 ? "启用" : "禁用"
                  }}</span>
                  <div v-else>
                    <el-radio v-model="userInfoForm.status" :label="1">启用</el-radio>
                    <el-radio v-model="userInfoForm.status" :label="0">禁用</el-radio>
                  </div>
                </el-form-item>
              </el-col> -->
                <el-col :span="!editingStatus ? 10 : 10">
                  <el-form-item label="用户分组:" prop="group_id">
                    <span v-if="!editingStatus">{{
                    userInfoForm.group_name ? userInfoForm.group_name : "-"
                  }}</span>
                    <el-select v-else v-model="userInfoForm.group_id" placeholder="请选择分组">
                      <el-option v-for="item in groupList" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="20">
                  <el-form-item label="用户标签:" prop="user_tag_id">
                    <div v-if="!editingStatus"
                      style="background-color: #f9f9f9;padding:0 10px;color:#629eff;font-size:12px;font-weight:550">
                      <div v-if="userInfoForm.user_tag_arr
                        ? userInfoForm.user_tag_arr.length !== 0
                        : false
                      ">
                        <span style="margin: 0 5px" v-for="(item, index) in userInfoForm.user_tag_arr" :key="index">{{
                        item }}</span>
                      </div>
                      <div v-else>-</div>
                    </div>
                    <el-select v-else @change="userInfoFormUsertagid" style="width: 100%" v-model="user_tag_id" multiple
                      placeholder="请选择标签">
                      <el-option-group v-for="group in TagCategoryAll" :key="group.category_name"
                        :label="group.category_name">
                        <el-option v-for="item in group.child" :key="item.id" :label="item.tag_name" :value="item.id">
                        </el-option>
                      </el-option-group>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="!editingStatus ? 10 : 10">
                  <el-form-item label="注册来源:" prop="">
                    <span>{{
                    userInfoForm.source_name ? userInfoForm.source_name : "-"
                  }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="!editingStatus ? 10 : 10">
                  <el-form-item label="账户状态:" prop="">
                    <span style="color: #629eff;font-weight: 550;">{{
                    userInfoForm.status_name ? userInfoForm.status_name : "-"
                  }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="!editingStatus ? 10 : 10">
                  <el-form-item label="注册时间:" prop="created_at">
                    <span v-if="!editingStatus">{{
                    userInfoForm.created_at ? userInfoForm.created_at : "-"
                  }}</span>
                    <el-date-picker disabled v-else value-format="yyyy-MM-dd" v-model="userInfoForm.created_at"
                      type="date" placeholder="选择日期">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <!-- <el-col :span="!editingStatus ? 10 : 10">
                <el-form-item
                  :style="!editingStatus ? 'margin-bottom:0' : ''"
                  label="登录时间"
                  prop="updated_at"
                >
                  <span v-if="!editingStatus">

                    -
                  </span>
                  <el-date-picker
                    v-else
                    disabled
                    value-format="yyyy-MM-dd"
                    v-model="userInfoForm.updated_at"
                    type="date"
                    placeholder="选择日期"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col> -->

                <!--



              <!-- <el-col :span="!editingStatus ? 10 : 10">
                <el-form-item
                  :style="!editingStatus ? 'margin-bottom:0' : ''"
                  label="邮箱:"
                  prop="email"
                >
                  <span v-if="!editingStatus">{{
                    userInfoForm.email ? userInfoForm.email : "-"
                  }}</span>
                  <el-input
                    v-else
                    type="text"
                    onkeyup="value=value.replace(/[\u4E00-\u9FA5]/g,'')"
                    placeholder="请输入邮箱"
                    v-model="userInfoForm.email"
                  ></el-input>
                </el-form-item>
              </el-col> -->
                <!-- <el-col :span="!editingStatus ? 10 : 10">
                <el-form-item
                  :style="!editingStatus ? 'margin-bottom:0' : ''"
                  label="手机号:"
                  prop="mobile"
                >
                  <span v-if="!editingStatus">{{
                    userInfoForm.mobile ? userInfoForm.mobile : "-"
                  }}</span>
                  <el-input
                    v-else
                    onkeyup="value=value.replace(/\D/g,'')"
                    placeholder="请输入手机号"
                    :maxlength="11"
                    v-model="userInfoForm.mobile"
                  ></el-input>
                </el-form-item>
              </el-col> -->
                <el-col :span="!editingStatus ? 10 : 10">
                  <el-form-item :style="!editingStatus ? 'margin-bottom:0' : ''" label="用户省份:" prop="province_id">
                    <span v-if="!editingStatus">{{
                    userInfoForm.province_name
                    ? userInfoForm.province_name
                    : "-"
                  }}</span>
                    <el-select v-else v-model="userInfoForm.province_id" @change="provinceWay" placeholder="请选择省份">
                      <el-option v-for="item in economizeList" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="!editingStatus ? 10 : 10">
                  <el-form-item label="用户城市:" prop="city_id">
                    <span v-if="!editingStatus">{{
                    userInfoForm.city_name ? userInfoForm.city_name : "-"
                  }}</span>
                    <el-select v-else v-model="userInfoForm.city_id" @change="cityWay" placeholder="请选择城市">
                      <el-option v-for="item in cityList" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <!-- <el-col :span="!editingStatus ? 10 : 10">
                <el-form-item

                  label="区县:"
                  prop="county_id"
                >
                  <span v-if="!editingStatus">{{
                    userInfoForm.county_name ? userInfoForm.county_name : "-"
                  }}</span>
                  <el-select
                    v-else
                    v-model="userInfoForm.county_id"
                    @change="countyWay"
                    placeholder="请选择区/县"
                  >
                    <el-option
                      v-for="item in countyList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col> -->
                <el-col :span="10">
                  <el-form-item :style="!editingStatus ? 'margin-bottom:0' : ''" label="用户地址:" prop="region">
                    <span v-if="!editingStatus">{{
                    userInfoForm.region ? userInfoForm.region : "-"
                  }}</span>
                    <el-input v-else type="text" v-model="userInfoForm.region"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="!editingStatus ? 10 : 10">
                  <el-form-item label="邀请码:" prop="">
                    <span>{{
                    userInfoForm.invitation_code ? userInfoForm.invitation_code : "-"
                  }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="20">
                  <el-form-item :style="!editingStatus ? 'margin-bottom:0' : ''" label="账户备注:" prop="remark">
                    <div style="width:500px;height:80px;background:#f7f8fa;padding:0 10px" v-if="!editingStatus">{{
                    userInfoForm.remark ? userInfoForm.remark : "--"
                  }}</div>
                    <el-input v-else v-model="userInfoForm.remark" type="textarea"
                      :autosize="{ minRows: 2, maxRows: 4 }" placeholder="请输入内容">
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="24" class="marginBottom marginTop">
                  <div class="blockquote-box">账户密码</div>
                </el-col>
                <el-col :span="!editingStatus ? 8 : 10">
                  <el-form-item :style="!editingStatus ? 'margin-bottom:0' : ''" label="登录密码:" prop="password">
                    <span v-if="!editingStatus">{{
                    infoPass ? "********" : "********"
                  }}</span>
                    <el-input v-else type="password" :show-password="true" :maxlength="16" :minlength="8"
                      onkeyup="value=value.replace(/[\u4E00-\u9FA5]/g,'')" placeholder="请输入登录密码"
                      v-model.trim="infoPass"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="!editingStatus ? 8 : 10">
                  <el-form-item :style="!editingStatus ? 'margin-bottom:0' : ''" label="支付密码:" prop="pay_password">
                    <span v-if="!editingStatus">{{
                    infoPayPass ? "********" : "********"
                  }}</span>
                    <el-input v-else type="password" onkeyup="value=value.replace(/\D/g,'')" :maxlength="6"
                      :minlength="6" :show-password="true" placeholder="请输入支付密码" v-model.trim="infoPayPass"></el-input>
                  </el-form-item>
                </el-col>
                <el-col v-if="editingStatus" :span="!editingStatus ? 8 : 10">
                  <el-form-item :style="!editingStatus ? 'margin-bottom:0' : ''" label="确认登录密码:"
                    prop="confirm_password">
                    <el-input type="password" :show-password="true" :maxlength="16" :minlength="8"
                      onkeyup="value=value.replace(/[\u4E00-\u9FA5]/g,'')" placeholder="请再次输入登录密码"
                      v-model.trim="confirmpwd"></el-input>
                  </el-form-item>
                </el-col>
                <el-col v-if="editingStatus" :span="!editingStatus ? 8 : 10">
                  <el-form-item :style="!editingStatus ? 'margin-bottom:0' : ''" label="确认支付密码:" prop="pay_password">
                    <el-input type="password" onkeyup="value=value.replace(/\D/g,'')" :maxlength="6" :minlength="6"
                      :show-password="true" placeholder="请再次输入支付密码" v-model.trim="confirmPaypwd"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="24" class="marginBottom marginTop">
                </el-col>
              </el-row>
            </el-form>
          </div>
        </div>
      </el-scrollbar>
      <el-col :span="24" style="text-align: right; padding-right: 30px;" v-if="activeNames == '基本信息'">
        <div class="right">
          <span v-hasPermi="'consumer/edit'">
            <el-button type="primary" icon="el-icon-circle-close" v-if="editingStatus" size="small" @click="() => {
                    editingStatus = false;
                  }
                  ">取消</el-button>
            <el-button style="margin-left: 10px" type="primary"
              :icon="!editingStatus ? 'el-icon-edit' : 'el-icon-finished'" size="small" @click="saveUserInfoWay">{{
                    !editingStatus ? "变更用户基本信息" : "保存" }}</el-button>
          </span>
        </div>
      </el-col>

    </el-drawer>
    <!-- 赠送余额积分 -->
    <el-dialog :close-on-click-modal="false" title="金额变更" :visible.sync="deductionGiftDialog" width="550px"
      @close="deductionhandleClose">
      <div v-if="modifyForm.modify == 1">
        <el-form label-width="80px" ref="modifyruless" class="demo-ruleForm" :model="modifyForm" :rules="modifyruless">
          <el-row :gutter="20">
            <el-col :span="22">
              <el-form-item label="变更类型" prop="type">
                <el-radio v-model="modifyForm.type" :label="1">增加</el-radio>
                <el-radio v-model="modifyForm.type" :label="2">扣除</el-radio>
              </el-form-item>
            </el-col>
            <el-col :span="22">
              <el-form-item label="变更金额" prop="balance">
                <el-input v-model="modifyForm.balance" type="number"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="22">
              <el-form-item label="变更备注" prop="remark">
                <el-input v-model="modifyForm.remark" type="textarea" :autosize="{ minRows: 2, maxRows: 4 }"
                  placeholder="请输入内容">
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <!-- </el-tab-pane> -->
      <!-- <el-tab-pane label="积分" name="2"> -->
      <div v-if="modifyForm.modify == 2">
        <el-form label-width="80px" ref="modifyrules" class="demo-ruleForm" :model="modifyForm" :rules="modifyrules">
          <el-row :gutter="20">
            <el-col :span="22">
              <el-form-item label="修改积分" prop="type">
                <el-radio v-model="modifyForm.type" :label="1">增加</el-radio>
                <el-radio v-model="modifyForm.type" :label="2">扣除</el-radio>
              </el-form-item>
            </el-col>
            <el-col :span="22">
              <el-form-item label="数量" prop="points">
                <el-input v-model="modifyForm.points" type="number"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="22">
              <el-form-item label="备注" prop="remark">
                <el-input v-model="modifyForm.remark" type="textarea" :autosize="{ minRows: 2, maxRows: 4 }"
                  placeholder="请输入内容">
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <!-- </el-tab-pane> -->
      </el-tabs>
      <span slot="footer" class="dialog-footer">
        <el-button @click="deductionGiftDialog = false">取 消</el-button>
        <el-button type="primary" @click="submitdeductionGift('modifyrules')">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 修改提货去 -->
    <el-dialog :close-on-click-modal="false" title="修改提货券" :visible.sync="editCouponDialog" width="550px"
      @close="editCouponClose">
      <el-form v-loading="editCouponLoading" label-width="80px" ref="editCouponForm" class="demo-ruleForm"
        :model="editCouponForm" :rules="editCouponRules">
        <el-row :gutter="20">
          <el-col :span="22">
            <el-form-item label="类型" prop="type">
              <el-radio v-model="editCouponForm.type" :label="1">增加</el-radio>
              <el-radio v-model="editCouponForm.type" :label="2">扣除</el-radio>
            </el-form-item>
          </el-col>
          <el-col :span="22">
            <el-form-item label="数量" prop="coupon">
              <el-input placeholder="请输入数额" v-model="editCouponForm.coupon" type="number"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="22">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="editCouponForm.remark" type="textarea" :autosize="{ minRows: 2, maxRows: 4 }"
                placeholder="请输入内容">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button :loading="editCouponLoading" @click="editCouponDialog = false">取 消</el-button>
        <el-button :loading="editCouponLoading" type="primary" @click="submiteditCoupon('editCouponForm')">确
          定</el-button>
      </span>
    </el-dialog>
    <!-- 发送优惠券弹框 -->
    <el-dialog :close-on-click-modal="false" title="发送优惠券" :visible.sync="couponsDialogVisible" width="800px"
      @close="couponsHandleClose">
      <el-form :inline="true" class="search-form">
        <el-form-item label="优惠券名称">
          <el-input clearable v-model="searchCoupon.CouponName" class="marginBottom" placeholder="请输入优惠券名称" />
        </el-form-item>
        <el-form-item label="优惠券类型">
          <el-select v-model="searchCoupon.type" placeholder="优惠券类型" clearable>
            <el-option label="满减劵" :value="1"></el-option>
            <el-option label="折扣券" :value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="small" @click="getCouponListWay">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="couponsLoading" highlight-current-row :data="couponsList" :header-cell-style="{
        'background-color': '#f3f8fe',
        color: '#606266',
        height: '50px',
      }" style="width: 100%">
        <el-table-column align="center" prop="name" label="优惠券名称">
        </el-table-column>
        <el-table-column align="center" prop="quota" label="优惠券面值">
        </el-table-column>
        <el-table-column align="center" prop="residue_limit" label="剩余数量">
          <template slot-scope="scope">
            {{
              scope.row.residue_limit == 0 && scope.row.is_limit !== 1
              ? "∞"
              : scope.row.residue_limit
            }}
          </template>
        </el-table-column>
        <el-table-column align="center" fixed="right" prop="address" label="操作">
          <template slot-scope="scope">
            <el-button type="warning" size="mini" @click="sendingWay(scope.row)">
              发送
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-row class="marginTop" style="text-align: right">
        <el-pagination @size-change="CouponSizeChange" @current-change="CouponCurrentChange"
          :current-page="searchCoupon.page" :page-sizes="[10, 20, 30, 40]" :page-size="searchCoupon.count"
          layout="total, sizes, prev, pager, next, jumper" :total="couponTotal">
        </el-pagination>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button @click="couponsDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="couponsDialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" title="请选择" :visible.sync="sendingDialogVisible" width="500px"
      @close="sendingsHandleClose">
      <el-row :gutter="20">
        <el-form :inline="false" label-width="80px" class="demo-ruleForm">
          <el-col :span="24">
            <el-form-item label="状态">
              <el-radio-group v-model="couponForm.type" size="mini">
                <el-radio :label="1" border>全部发放</el-radio>
                <el-radio :label="2" border>部分发放</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="22">
            <el-form-item label="备注">
              <el-input show-word-limit style="width: 100%" placeholder="请输入赠送优惠券的说明" v-model="couponForm.admin_remark"
                type="textarea" :autosize="{ minRows: 2, maxRows: 4 }" maxlength="200" />
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button @click="sendingDialogVisible = false">取 消</el-button>
        <el-button :loading="fsyhjLoading" type="primary" @click="faosngyouhuiquan">确 定</el-button>
      </span>
    </el-dialog>

    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="变更记录" size="40%" :withHeader="false"
      :visible.sync="dialogLabel" @close="CloseDialogLabel" :show-close="true">
      <div style="position: relative;margin-bottom: 30px;">
        <div class="drawerTitle">
          <span>变更记录</span>
          <div class="close" @click="CloseDialogLabel">
            <i class="el-icon-close" style="font-size: 24px;"></i>
          </div>
        </div>
      </div>
      <el-scrollbar wrap-style="overflow-x:hidden;" style="height: calc(100vh - 185px)">
        <el-row style="font-size: 14px;padding-left: 40px;color: #6c6c6c;font-weight: 550;"
          v-if="userInfoForm.is_real_auth == 1">
          <el-col :span="12" style="margin-bottom: 20px;">
            实名时间：<span v-if="userInfoForm.real_name_info.created_at">{{userInfoForm.real_name_info.created_at}}</span>
          </el-col>
          <el-col :span="9" style="margin-bottom: 20px;">
            处理状态：<span style="color: #c33124;">同意</span>
          </el-col>
          <el-col :span="20" style="margin-bottom: 20px;">
            处理人：系统
          </el-col>
          <el-col :span="20">
            <div class="reason_for_rejection">备注信息：</div>
          </el-col>
        </el-row>
        <el-row style="font-size: 14px;padding-left: 40px;color: #6c6c6c;font-weight: 550;" v-else>
          <el-col :span="12" style="margin-bottom: 20px;">
            未实名
          </el-col>
        </el-row>
      </el-scrollbar>
      <el-col :span="24" style="text-align: right; padding-right: 30px;">

        <el-button type="primary" @click="CloseDialogLabel">关闭</el-button>
      </el-col>
    </el-drawer>



    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="余额明细" size="65%" :withHeader="false"
      :visible.sync="open_balancedetails" @close="closing_balance_details" :show-close="true">
      <div class="drawerTitle">
        <span>余额明细</span>
        <div class="close" @click="closing_balance_details">
          <i class="el-icon-close" style="font-size: 24px;"></i>
        </div>
      </div>
      <el-scrollbar wrap-style="overflow-x:hidden;" style="height: calc(100vh - 80px)">
        <div style="padding: 10px 30px">
          <div class="infoDivTop">

          </div>
          <div class="infoDiv" style="">
            <div class="img" style="overflow: hidden">
              <el-image style="width: 100%; height: 100%" :src="userInfoForm.avatar" fit="cover"></el-image>
            </div>
            <div class="scenter">
              <div class="order_center">
                <div>
                  <div class="orderdetail_item orderdetail_items">
                    <p>用户昵称：</p>
                    <p>
                      {{
                      userInfoForm.nickname
                      ? userInfoForm.nickname
                      : "--"
                    }}
                    </p>
                  </div>
                  <div class="orderdetail_item">
                    <p>用户区域：</p>
                    <p>
                      {{
                      userInfoForm.province_name
                      ? userInfoForm.province_name + userInfoForm.city_name
                      : "--"
                    }}
                    </p>
                  </div>
                </div>
                <div>
                  <div class="orderdetail_item">
                    <p>可用余额：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.available_balance
                      : "0.00"
                    }}
                    </p>
                  </div>
                  <div class="orderdetail_item">
                    <p>冻结余额：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.locked_balance
                      : "0.00"
                    }}
                    </p>
                  </div>
                </div>
              </div>
            </div>
            <div class="right">
              <div class="order_center">
                <div class="orderdetail_item">
                  <p>实名状态：</p>
                  <p style="color:#567722;font-weight: 550;">
                    {{
                    userInfoForm.is_real_auth == 1
                    ? '已实名'
                    : "未实名"
                  }}
                  </p>
                </div>


              </div>
            </div>
          </div>

          <el-row :gutter="20">
            <el-form :inline="true" class="search-form">
              <el-col :span="24" class="">
                <el-form-item label="收支类型：">
                  <el-select v-model="BalanceSearch.type" placeholder="请选择收支类型">
                    <el-option v-for="item in [
                        { name: '收入', id: 1 },
                        { name: '支出', id: 2 },
                      ]" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="关联类型：">
                  <el-select v-model="BalanceSearch.link_type" placeholder="请选择关联类型">
                    <el-option v-for="item in [
                        { name: '充值', id: 1 },
                        { name: '消费支出', id: 2 },
                        { name: '系统奖励', id: 3 },
                      ]" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item style="float: right">
                  <el-button type="primary" icon="el-icon-search" @click="getBalanceListWay">查询</el-button>
                  <el-button type="primary" icon="el-icon-refresh" @click="resettingBalance">重置</el-button>
                  <el-button v-if="!hiddenbalance" type="warning" icon="el-icon-caret-bottom"
                    @click="hiddenbalance = true">展开</el-button>
                  <el-button v-else type="warning" icon="el-icon-caret-top"
                    @click="hiddenbalance = false">收起</el-button>
                </el-form-item>
              </el-col>
              <el-col :span="24" class="marginTop" v-if="hiddenbalance">
                <el-form-item label="时间范围：">
                  <el-date-picker value-format="yyyy-MM-dd" v-model="balanceTime" type="daterange"
                    align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
                    :picker-options="pickerOptions">
                  </el-date-picker>
                </el-form-item>

              </el-col>
              <el-col :span="24" class="">
                <el-divider></el-divider>

              </el-col>
            </el-form>
            <el-col :span="20" style="margin-bottom: 20px;">
              <el-button v-hasPermi="'consumer/give'" type="primary" size="small" @click="deductionGift()"
                icon="el-icon-circle-plus-outline">余额变更</el-button>
            </el-col>
            <el-col :span="4" style="float: right">
            </el-col>
            <el-col :span="24" v-loading="subLoading">
              <el-table highlight-current-row :data="BalanceList" :header-cell-style="{
                  'background-color': '#f3f8fe',
                  color: '#606266',
                  height: '50px',
                }" style="width: 100%">
                <el-table-column align="center" prop="id" label="ID" width="80">
                </el-table-column>
                <el-table-column align="center" prop="type" label="收支类型">
                  <template slot-scope="scope">
                    <span v-if="scope.row.type == 1" style="color:#1890ff;">增加</span>
                    <span v-else style="color:#bd3124;">支出</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="link_type" label="业务类型">
                  <template slot-scope="scope">
                    <span style="color:#1890ff;">{{scope.row.link_type_name}}</span>

                  </template>
                </el-table-column>
                <el-table-column align="center" prop="balance_change" label="变更额度">
                </el-table-column>
                <el-table-column align="center" prop="after_balance" label="变更后">
                </el-table-column>
                <el-table-column align="center" prop="remark" label="备注">
                  <template slot-scope="scope">
                    <el-tooltip placement="top-start" :content="scope.row.remark">
                      <div class="one_line_hidden">
                        {{ scope.row.remark ? scope.row.remark : "-" }}
                      </div>
                    </el-tooltip>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="created_at" label="创建时间">
                  <template slot-scope="scope">
                    <el-tooltip placement="top-start" :content="scope.row.created_at">
                      <div class="one_line_hidden">
                        {{ scope.row.created_at ? scope.row.created_at : "-" }}
                      </div>
                    </el-tooltip>
                  </template>
                </el-table-column>
                <el-table-column align="center" fixed="right" width="120" prop="" label="操作">
                  <template slot-scope="scope">
                    <el-button type="primary" size="mini" @click="popupbalances(scope.row)">
                      详情
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
            <el-col class="marginTop" style="text-align: right">
              <el-pagination @size-change="handleBalanceSizeChange" @current-change="handleBalanceCurrentChange"
                :current-page="BalanceSearch.page" :page-sizes="[10, 20, 30, 40]" :page-size="BalanceSearch.count"
                layout="total, sizes, prev, pager, next, jumper" :total="totalBalance">
              </el-pagination>
            </el-col>
          </el-row>
        </div>
      </el-scrollbar>
    </el-drawer>
    <!--  -->
    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="余额明细" size="60%" :withHeader="false"
      :visible.sync="popupbalancedetails" @close="popup_balance_details" :show-close="true">
      <div class="drawerTitle">
        <span>用户余额变更详情</span>
        <div class="close" @click="popup_balance_details">
          <i class="el-icon-close" style="font-size: 24px;"></i>
        </div>
      </div>
      <el-scrollbar wrap-style="overflow-x:hidden;" style="height: calc(100vh - 80px)">
        <div style="padding: 10px 30px">
          <el-form :model="userInfoForm" status-icon :rules="inforules" ref="inforules" label-width="100px"
            class="demo-ruleForm">
            <el-row :gutter="10" style="display: flex; flex-wrap: wrap">
              <el-col :span="24" class="marginBottom">
                <div class="blockquote-box" style="display:flex;justify-content:space-between">
                  <span style="flex:1">变更详情</span>
                </div>
              </el-col>
              <el-col :span="10">
                <el-form-item label="记录ID:">
                  <span v-if="popupbalancex.id">{{
                  popupbalancex.id
                }}</span>
                  <span v-else>-</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="收支类型:">
                  <span style="color: #629eff;font-weight: 550;">{{popupbalancex.type == 1 ? '增加' : '减少'}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="业务类型:">
                  <span style="color: #629eff;font-weight: 550;" v-if="popupbalancex.link_type_name">{{
                  popupbalancex.link_type_name
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="关联订单:">
                  <span v-if="popupbalancex.link_id">{{
                  popupbalancex.link_id
                }}</span>
                  <span v-else>-</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="变更额度:">
                  <span>{{
                  popupbalancex.balance_change ? popupbalancex.balance_change : "-"
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="变更后:">
                  <span>{{
                  popupbalancex.after_balance ? popupbalancex.after_balance : "-"
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="变更时间:">
                  <span>{{
                  popupbalancex.created_at ? popupbalancex.created_at : "-"
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="冻结期:">
                  <span>{{
                  popupbalancex.frozen_time ? popupbalancex.frozen_time : "无"
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="24" class="marginBottom">
                <div class="blockquote-box" style="display:flex;justify-content:space-between">
                  <span style="flex:1">变更信息</span>
                </div>
              </el-col>
              <el-col :span="20">
                <el-form-item label="变更人员:">
                  <span>{{popupbalancex.admin_name ? popupbalancex.admin_name : '无'}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="20">
                <el-form-item label="变更备注:">
                  <span>{{
                  popupbalancex.remark ? popupbalancex.remark : "-"
                }}</span>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
      </el-scrollbar>
    </el-drawer>
    <!-- jifen -->
    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="积分明细" size="65%" :withHeader="false"
      :visible.sync="open_pointdetails" @close="closing_point_details" :show-close="true">
      <div class="drawerTitle">
        <span>积分明细</span>
        <div class="close" @click="closing_point_details">
          <i class="el-icon-close" style="font-size: 24px;"></i>
        </div>
      </div>
      <el-scrollbar wrap-style="overflow-x:hidden;" style="height: calc(100vh - 80px)">
        <div style="padding: 10px 30px">
          <div class="infoDivTop">

          </div>
          <div class="infoDiv" style="">
            <div class="img" style="overflow: hidden">
              <el-image style="width: 100%; height: 100%" :src="userInfoForm.avatar" fit="cover"></el-image>
            </div>
            <div class="scenter">
              <div class="order_center">
                <div>
                  <div class="orderdetail_item orderdetail_items">
                    <p>用户昵称：</p>
                    <p>
                      {{
                      userInfoForm.nickname
                      ? userInfoForm.nickname
                      : "--"
                    }}
                    </p>
                  </div>
                  <div class="orderdetail_item">
                    <p>用户区域：</p>
                    <p>
                      {{
                      userInfoForm.province_name
                      ? userInfoForm.province_name + userInfoForm.city_name
                      : "--"
                    }}
                    </p>
                  </div>
                </div>
                <div>
                  <div class="orderdetail_item">
                    <p>可用积分：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.available_points
                      : "0.00"
                    }}
                    </p>
                  </div>


                  <div class="orderdetail_item">
                    <p>冻结积分：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.locked_points
                      : "0.00"
                    }}
                    </p>
                  </div>
                </div>
              </div>
            </div>
            <div class="right">
              <div class="order_center">
                <div class="orderdetail_item">
                  <p>实名状态：</p>
                  <p style="color:#567722;font-weight: 550;">
                    {{
                    userInfoForm.is_real_auth == 1
                    ? '已实名'
                    : "未实名"
                  }}
                  </p>
                </div>
              </div>
            </div>
          </div>

          <el-row :gutter="20">
            <el-form :inline="true" class="search-form">
              <el-col :span="24" class="">
                <el-form-item label="收支类型：">
                  <el-select v-model="IntegralSearch.type" placeholder="请选择收支类型">
                    <el-option v-for="item in [
                        { name: '收入', id: 1 },
                        { name: '支出', id: 2 },
                      ]" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="关联类型：">
                  <el-select v-model="IntegralSearch.link_type" placeholder="请选择关联类型">
                    <el-option v-for="item in [
                        { name: '充值', id: 1 },
                        { name: '消费支出', id: 2 },
                        { name: '系统奖励', id: 3 },
                      ]" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item style="float: right">
                  <el-button type="primary" icon="el-icon-search" @click="getIntegralListWay">查询</el-button>
                  <el-button type="primary" icon="el-icon-refresh" @click="resettingIntegral">重置</el-button>
                  <el-button v-if="!hiddenpoint" type="warning" icon="el-icon-caret-bottom"
                    @click="hiddenpoint = true">展开</el-button>
                  <el-button v-else type="warning" icon="el-icon-caret-top" @click="hiddenpoint = false">收起</el-button>
                </el-form-item>
              </el-col>
              <el-col :span="24" class="marginTop" v-if="hiddenpoint">
                <el-form-item label="时间范围：">
                  <el-date-picker value-format="yyyy-MM-dd" v-model="IntegralTime" type="daterange"
                    align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
                    :picker-options="pickerOptions">
                  </el-date-picker>
                </el-form-item>

              </el-col>
              <el-col :span="24" class="">
                <el-divider></el-divider>

              </el-col>
            </el-form>
            <el-col :span="20" style="margin-bottom: 20px;">
              <el-button v-hasPermi="'consumer/give'" type="primary" size="small" @click="deductionGiftpoint()"
                icon="el-icon-circle-plus-outline">积分变更</el-button>
            </el-col>
            <el-col :span="24" v-loading="subLoading">
              <el-table highlight-current-row :data="IntegralList" :header-cell-style="{
                  'background-color': '#f3f8fe',
                  color: '#606266',
                  height: '50px',
                }" style="width: 100%">
                <el-table-column align="center" prop="id" label="ID">
                </el-table-column>
                <el-table-column align="center" prop="type" label="收支类型">
                  <template slot-scope="scope">
                    <span v-if="scope.row.type == 1" style="color:#1890ff;">增加</span>
                    <span v-else style="color:#bd3124;">支出</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="link_type" label="关联类型">
                  <template slot-scope="scope">
                    <span style="color:#1890ff;">{{scope.row.link_type_name}}</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="integral" label="变化额度">
                </el-table-column>
                <el-table-column align="center" prop="after_integral" label="变化后">
                </el-table-column>
                <el-table-column align="center" prop="remark" label="备注">
                  <template slot-scope="scope">
                    <el-tooltip placement="top-start" :content="scope.row.remark">
                      <div class="one_line_hidden">
                        {{ scope.row.remark ? scope.row.remark : "-" }}
                      </div>
                    </el-tooltip>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="created_at" label="创建时间">
                  <template slot-scope="scope">
                    <el-tooltip placement="top-start" :content="scope.row.created_at">
                      <div class="one_line_hidden">
                        {{ scope.row.created_at ? scope.row.created_at : "-" }}
                      </div>
                    </el-tooltip>
                  </template>
                </el-table-column>
                <el-table-column align="center" fixed="right" width="120" prop="" label="操作">
                  <template slot-scope="scope">
                    <el-button type="primary" size="mini" @click="popuppoints(scope.row)">
                      详情
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
            <el-col class="marginTop" style="text-align: right">
              <el-pagination @size-change="handleIntegralSizeChange" @current-change="handleIntegralCurrentChange"
                :current-page="IntegralSearch.page" :page-sizes="[10, 20, 30, 40]" :page-size="IntegralSearch.count"
                layout="total, sizes, prev, pager, next, jumper" :total="totalIntegral">
              </el-pagination>
            </el-col>
          </el-row>

        </div>
      </el-scrollbar>
    </el-drawer>
    <!--  -->
    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="积分明细" size="60%" :withHeader="false"
      :visible.sync="popuppointdetails" @close="popup_point_details" :show-close="true">
      <div class="drawerTitle">
        <span>用户积分变更详情</span>
        <div class="close" @click="popup_point_details">
          <i class="el-icon-close" style="font-size: 24px;"></i>
        </div>
      </div>
      <el-scrollbar wrap-style="overflow-x:hidden;" style="height: calc(100vh - 80px)">
        <div style="padding: 10px 30px">
          <el-form :model="userInfoForm" status-icon :rules="inforules" ref="inforules" label-width="100px"
            class="demo-ruleForm">
            <el-row :gutter="10" style="display: flex; flex-wrap: wrap">
              <el-col :span="24" class="marginBottom">
                <div class="blockquote-box" style="display:flex;justify-content:space-between">
                  <span style="flex:1">变更详情</span>
                </div>
              </el-col>
              <el-col :span="10">
                <el-form-item label="记录ID:">
                  <span v-if="popuppointx.id">{{
                  popuppointx.id
                }}</span>
                  <span v-else>-</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="收支类型:">
                  <span style="color: #629eff;font-weight: 550;">{{popuppointx.type == 1 ? '增加' : '减少'}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="业务类型:">
                  <span style="color: #629eff;font-weight: 550;" v-if="popuppointx.link_type_name">{{
                  popuppointx.link_type_name
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="关联订单:">
                  <span v-if="popuppointx.link_id">{{
                  popuppointx.link_id
                }}</span>
                  <span v-else>-</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="变更额度:">
                  <span>{{
                  popuppointx.integral ? popuppointx.integral : "-"
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="变更后:">
                  <span>{{
                  popuppointx.after_integral ? popuppointx.after_integral : "-"
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="变更时间:">
                  <span>{{
                  popuppointx.created_at ? popuppointx.created_at : "-"
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="冻结期:">
                  <span>{{
                  popuppointx.frozen_time ? popuppointx.frozen_time : "无"
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="24" class="marginBottom">
                <div class="blockquote-box" style="display:flex;justify-content:space-between">
                  <span style="flex:1">变更信息</span>
                </div>
              </el-col>
              <el-col :span="20">
                <el-form-item label="变更人员:">
                  <span>{{popuppointx.admin_name ? popuppointx.admin_name : '无'}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="20">
                <el-form-item label="变更备注:">
                  <span>{{
                  popuppointx.remark ? popuppointx.remark : "-"
                }}</span>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
      </el-scrollbar>
    </el-drawer>
    <!-- 提货券 -->
    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="提货券明细" size="65%" :withHeader="false"
      :visible.sync="open_vourderdetails" @close="closing_vourder_details" :show-close="true">
      <div class="drawerTitle">
        <span>提货券明细</span>
        <div class="close" @click="closing_vourder_details">
          <i class="el-icon-close" style="font-size: 24px;"></i>
        </div>
      </div>
      <el-scrollbar wrap-style="overflow-x:hidden;" style="height: calc(100vh - 80px)">
        <div style="padding: 10px 30px">
          <div class="infoDivTop">

          </div>
          <div class="infoDiv" style="">
            <div class="img" style="overflow: hidden">
              <el-image style="width: 100%; height: 100%" :src="userInfoForm.avatar" fit="cover"></el-image>
            </div>
            <div class="scenter">
              <div class="order_center">
                <div>
                  <div class="orderdetail_item orderdetail_items">
                    <p>用户昵称：</p>
                    <p>
                      {{
                      userInfoForm.nickname
                      ? userInfoForm.nickname
                      : "--"
                    }}
                    </p>
                  </div>
                  <div class="orderdetail_item">
                    <p>用户区域：</p>
                    <p>
                      {{
                      userInfoForm.province_name
                      ? userInfoForm.province_name + userInfoForm.city_name
                      : "--"
                    }}
                    </p>
                  </div>
                </div>
                <div>
                  <div class="orderdetail_item">
                    <p>可用提货券：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.available_coupons
                      : "0.00"
                    }}
                    </p>
                  </div>


                  <div class="orderdetail_item">
                    <p>冻结提货券：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.locked_coupons
                      : "0.00"
                    }}
                    </p>
                  </div>
                </div>
              </div>
            </div>
            <div class="right">
              <div class="order_center">
                <div class="orderdetail_item">
                  <p>实名状态：</p>
                  <p style="color:#567722;font-weight: 550;">
                    {{
                    userInfoForm.is_real_auth == 1
                    ? '已实名'
                    : "未实名"
                  }}
                  </p>
                </div>
              </div>
            </div>
          </div>
          <el-row :gutter="20">
            <el-form :inline="true" class="search-form">
              <el-col :span="24" class="">
                <el-form-item label="收支类型：">
                  <el-select v-model="VoucherSearch.type" placeholder="请选择收支类型">
                    <el-option v-for="item in [
                        { name: '收入', id: 1 },
                        { name: '支出', id: 2 },
                      ]" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="关联类型：">
                  <el-select v-model="VoucherSearch.link_type" placeholder="请选择关联类型">
                    <el-option v-for="item in [
                        { name: '充值', id: 1 },
                        { name: '消费支出', id: 2 },
                        { name: '系统奖励', id: 3 },
                      ]" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item style="float: right">
                  <el-button type="primary" icon="el-icon-search" @click="getVoucherListWay">查询</el-button>
                  <el-button type="primary" icon="el-icon-refresh" @click="resettingVoucher">重置</el-button>
                  <el-button v-if="!hiddenvourder" type="warning" icon="el-icon-caret-bottom"
                    @click="hiddenvourder = true">展开</el-button>
                  <el-button v-else type="warning" icon="el-icon-caret-top"
                    @click="hiddenvourder = false">收起</el-button>
                </el-form-item>
              </el-col>
              <el-col :span="24" class="marginTop" v-if="hiddenvourder">
                <el-form-item label="时间范围：">
                  <el-date-picker value-format="yyyy-MM-dd" v-model="VoucherTime" type="daterange"
                    align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
                    :picker-options="pickerOptions">
                  </el-date-picker>
                </el-form-item>

              </el-col>
              <el-col :span="24" class="">
                <el-divider></el-divider>

              </el-col>
            </el-form>
            <el-col :span="20" style="margin-bottom: 20px;">
              <el-button v-hasPermi="'consumer/coupons'" type="primary" size="small" @click="editCouponWay()"
                icon="el-icon-circle-plus-outline">提货券变更</el-button>
            </el-col>
            <el-col :span="24" v-loading="subLoading">
              <el-table highlight-current-row :data="VoucherList" :header-cell-style="{
                  'background-color': '#f3f8fe',
                  color: '#606266',
                  height: '50px',
                }" style="width: 100%">
                <el-table-column align="center" prop="id" label="ID">
                </el-table-column>
                <el-table-column align="center" prop="type" label="收支类型">
                  <template slot-scope="scope">
                    <span v-if="scope.row.type == 1" style="color:#1890ff;">增加</span>
                    <span v-else style="color:#bd3124;">支出</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="link_type" label="关联类型">
                  <template slot-scope="scope">
                    <span style="color:#1890ff;">{{scope.row.link_type_name}}</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="voucher_change" label="变化额度">
                </el-table-column>
                <el-table-column align="center" prop="after_voucher" label="变化后">
                </el-table-column>
                <el-table-column align="center" prop="remark" label="备注">
                  <template slot-scope="scope">
                    <el-tooltip placement="top-start" :content="scope.row.remark">
                      <div class="one_line_hidden">
                        {{ scope.row.remark ? scope.row.remark : "-" }}
                      </div>
                    </el-tooltip>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="created_at" label="创建时间">
                  <template slot-scope="scope">
                    <el-tooltip placement="top-start" :content="scope.row.created_at">
                      <div class="one_line_hidden">
                        {{ scope.row.created_at ? scope.row.created_at : "-" }}
                      </div>
                    </el-tooltip>
                  </template>
                </el-table-column>
                <el-table-column align="center" fixed="right" width="120" prop="" label="操作">
                  <template slot-scope="scope">
                    <el-button type="primary" size="mini" @click="popupvoures(scope.row)">
                      详情
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
            <el-col class="marginTop" style="text-align: right">
              <el-pagination @size-change="handleVoucherSizeChange" @current-change="handleVoucherCurrentChange"
                :current-page="IntegralSearch.page" :page-sizes="[10, 20, 30, 40]" :page-size="IntegralSearch.count"
                layout="total, sizes, prev, pager, next, jumper" :total="totalIntegral">
              </el-pagination>
            </el-col>
          </el-row>
        </div>
      </el-scrollbar>
    </el-drawer>
    <!-- 提货券 -->
    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="提货券明细" size="60%" :withHeader="false"
      :visible.sync="popupvouerdetails" @close="popup_vouer_details" :show-close="true">
      <div class="drawerTitle">
        <span>用户提货券变更详情</span>
        <div class="close" @click="popup_vouer_details">
          <i class="el-icon-close" style="font-size: 24px;"></i>
        </div>
      </div>
      <el-scrollbar wrap-style="overflow-x:hidden;" style="height: calc(100vh - 80px)">
        <div style="padding: 10px 30px">
          <el-form :model="userInfoForm" status-icon :rules="inforules" ref="inforules" label-width="100px"
            class="demo-ruleForm">
            <el-row :gutter="10" style="display: flex; flex-wrap: wrap">
              <el-col :span="24" class="marginBottom">
                <div class="blockquote-box" style="display:flex;justify-content:space-between">
                  <span style="flex:1">变更详情</span>
                </div>
              </el-col>
              <el-col :span="10">
                <el-form-item label="记录ID:">
                  <span v-if="popuvouer.id">{{
                  popuvouer.id
                }}</span>
                  <span v-else>-</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="收支类型:">
                  <span style="color: #629eff;font-weight: 550;">{{popuvouer.type == 1 ? '增加' : '减少'}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="业务类型:">
                  <span style="color: #629eff;font-weight: 550;" v-if="popuvouer.link_type_name">{{
                  popuvouer.link_type_name
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="关联订单:">
                  <span v-if="popuvouer.order_no">{{
                  popuvouer.order_no
                }}</span>
                  <span v-else>-</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="变更额度:">
                  <span>{{
                  popuvouer.voucher_change ? popuvouer.voucher_change : "-"
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="变更后:">
                  <span>{{
                  popuvouer.after_voucher ? popuvouer.after_voucher : "-"
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="变更时间:">
                  <span>{{
                  popuvouer.created_at ? popuvouer.created_at : "-"
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="24" class="marginBottom">
                <div class="blockquote-box" style="display:flex;justify-content:space-between">
                  <span style="flex:1">变更信息</span>
                </div>
              </el-col>
              <el-col :span="20">
                <el-form-item label="变更人员:">
                  <span>{{popuvouer.admin_name ? popuvouer.admin_name : '无'}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="20">
                <el-form-item label="变更备注:">
                  <span>{{
                  popuvouer.remark ? popuvouer.remark : "-"
                }}</span>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
      </el-scrollbar>
    </el-drawer>
    <!-- 优惠券 -->
    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="优惠券明细" size="65%" :withHeader="false"
      :visible.sync="open_coupondetails" @close="closing_coupon_details" :show-close="true">
      <div class="drawerTitle">
        <span>优惠券明细</span>
        <div class="close" @click="closing_coupon_details">
          <i class="el-icon-close" style="font-size: 24px;"></i>
        </div>
      </div>
      <el-scrollbar wrap-style="overflow-x:hidden;" style="height: calc(100vh - 80px)">
        <div style="padding: 10px 30px">
          <div class="infoDivTop">
          </div>
          <div class="infoDiv" style="">
            <div class="img" style="overflow: hidden">
              <el-image style="width: 100%; height: 100%" :src="userInfoForm.avatar" fit="cover"></el-image>
            </div>
            <div class="scenter">
              <div class="order_center">
                <div>
                  <div class="orderdetail_item orderdetail_items">
                    <p>用户昵称：</p>
                    <p>
                      {{
                      userInfoForm.nickname
                      ? userInfoForm.nickname
                      : "--"
                    }}
                    </p>
                  </div>
                  <div class="orderdetail_item">
                    <p>用户区域：</p>
                    <p>
                      {{
                      userInfoForm.province_name
                      ? userInfoForm.province_name + userInfoForm.city_name
                      : "--"
                    }}
                    </p>
                  </div>
                </div>
                <div>
                  <div class="orderdetail_item">
                    <p>可用余额：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.available_balance
                      : "0.00"
                    }}
                    </p>
                  </div>
                  <div class="orderdetail_item">
                    <p>冻结余额：</p>
                    <p>
                      {{
                      userInfoForm.wallet
                      ? userInfoForm.wallet.locked_balance
                      : "0.00"
                    }}
                    </p>
                  </div>
                </div>
              </div>
            </div>
            <div class="right">
              <div class="order_center">
                <div class="orderdetail_item">
                  <p>实名状态：</p>
                  <p style="color:#567722;font-weight: 550;">
                    {{
                    userInfoForm.is_real_auth == 1
                    ? '已实名'
                    : "未实名"
                  }}
                  </p>
                </div>
              </div>
            </div>
          </div>
          <el-row :gutter="20">
            <el-form :inline="true" class="search-form">
              <el-col :span="24" class="">
                <el-form-item label="优惠券类型：">
                  <el-select v-model="searchcouponForm.coupon_type" placeholder="请选择优惠券类型">
                    <el-option v-for="item in [
                        { name: '满减券', id: 1 },
                        { name: '折扣券', id: 2 },
                      ]" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="使用状态：">
                  <el-select v-model="searchcouponForm.is_use" placeholder="请选择关联类型">
                    <el-option v-for="item in [
                        { name: '未使用', id: 1 },
                        { name: '使用中', id: 2 },
                        { name: '已使用', id: 3 },
                      ]" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item style="float: right">
                  <el-button type="primary" icon="el-icon-search" @click="getListcoupon">查询</el-button>
                  <el-button type="primary" icon="el-icon-refresh" @click="resettingcoupon">重置</el-button>
                  <el-button v-if="!hiddencoupon" type="warning" icon="el-icon-caret-bottom"
                    @click="hiddencoupon = true">展开</el-button>
                  <el-button v-else type="warning" icon="el-icon-caret-top"
                    @click="hiddencoupon = false">收起</el-button>
                </el-form-item>
              </el-col>
              <el-col :span="24" class="marginTop" v-if="hiddencoupon">
                <el-form-item label="领取时间：">
                  <el-date-picker value-format="yyyy-MM-dd" v-model="couponTime" type="daterange"
                    align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
                    :picker-options="pickerOptions">
                  </el-date-picker>
                </el-form-item>

              </el-col>
              <el-col :span="24" class="">
                <el-divider></el-divider>

              </el-col>
            </el-form>
            <el-col :span="20" style="margin-bottom: 20px;">
              <el-button v-hasPermi="'consumer/coupon'" type="primary" size="small" @click="single_sendCouponsWay(userInfoForm)"
                icon="el-icon-circle-plus-outline">发放优惠券</el-button>
            </el-col>
            <el-col :span="4" style="float: right">

            </el-col>
            <el-col :span="24" v-loading="couponLoading">
              <el-table highlight-current-row :data="CouponUserList" :header-cell-style="{
                  'background-color': '#f3f8fe',
                  color: '#606266',
                  height: '50px',
                }" style="width: 100%">
                <el-table-column align="center" prop="id" label="ID" width="80">
                </el-table-column>
                <el-table-column align="center" prop="coupon_type" label="卡券类型">
                  <template slot-scope="scope">
                    <span v-if="scope.row.coupon_type == 1">满减券</span>
                    <span v-else>折扣券</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="get_way" label="业务类型">
                  <template slot-scope="scope">
                    <span style="color:#1890ff;" v-if="scope.row.get_way == 1">新人礼赠送</span>
                    <span style="color:#1890ff;" v-if="scope.row.get_way == 2">新人礼赠送</span>
                    <span style="color:#1890ff;" v-if="scope.row.get_way == 3">手动领取</span>
                    <span style="color:#1890ff;" v-if="scope.row.get_way == 4">平台发放</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="is_use" label="使用状态">
                  <template slot-scope="scope">
                    <span style="color: #666666;" v-if="scope.row.is_use == 1">过期</span>
                    <span style="color:#bd3124;" v-if="scope.row.is_use == 2">未使用</span>
                    <span v-if="scope.row.is_use == 3">已使用</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="quota" label="面值">
                </el-table-column>
                <el-table-column align="center" prop="created_at" label="领取时间">
                  <template slot-scope="scope">
                    <el-tooltip placement="top-start" :content="scope.row.created_at">
                      <div class="one_line_hidden">
                        {{ scope.row.created_at ? scope.row.created_at : "-" }}
                      </div>
                    </el-tooltip>
                  </template>
                </el-table-column>
                <el-table-column align="center" fixed="right" width="120" prop="" label="操作">
                  <template slot-scope="scope">
                    <el-button type="primary" size="mini" @click="popupcoupon(scope.row)">
                      详情
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
            <el-col class="marginTop" style="text-align: right">
              <el-pagination @size-change="handlecouponSizeChange" @current-change="handlecouponCurrentChange"
                :current-page="searchcouponForm.page" :page-sizes="[10, 20, 30, 40]" :page-size="searchcouponForm.count"
                layout="total, sizes, prev, pager, next, jumper" :total="totalcoupon">
              </el-pagination>
            </el-col>
          </el-row>

        </div>
      </el-scrollbar>
    </el-drawer>
    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="用户优惠券详情" size="60%" :withHeader="false"
      :visible.sync="popupcoupondetails" @close="popup_coupon_details" :show-close="true">
      <div class="drawerTitle">
        <span>用户优惠券详情</span>
        <div class="close" @click="popup_coupon_details">
          <i class="el-icon-close" style="font-size: 24px;"></i>
        </div>
      </div>
      <el-scrollbar wrap-style="overflow-x:hidden;" style="height: calc(100vh - 80px)">
        <div style="padding: 10px 30px">
          <el-form status-icon label-width="130px"
            class="demo-ruleForm">
            <el-row :gutter="10" style="display: flex; flex-wrap: wrap">
              <el-col :span="24" class="marginBottom">
                <div class="blockquote-box" style="display:flex;justify-content:space-between">
                  <span style="flex:1">优惠券详情</span>
                </div>
              </el-col>
              <el-col :span="10">
                <el-form-item label="优惠券ID:">
                  <span v-if="popupcouponx.id">{{
                  popupcouponx.id
                }}</span>
                  <span v-else>-</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="卡券类型:">
                  <span style="color: #629eff;font-weight: 550;">{{popupcouponx.coupon_type == 1 ? '满减券' : '折扣券'}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="业务类型:">
                  <span style="color:#1890ff;" v-if="popupcouponx.get_way == 1">新人礼赠送</span>
                  <span style="color:#1890ff;" v-if="popupcouponx.get_way == 2">新人礼赠送</span>
                  <span style="color:#1890ff;" v-if="popupcouponx.get_way == 3">手动领取</span>
                  <span style="color:#1890ff;" v-if="popupcouponx.get_way == 4">平台发放</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="使用状态:">
                  <span style="color: #666666;" v-if="popupcouponx.is_use == 1">已过期</span>
                  <span style="color:#bd3124;" v-if="popupcouponx.is_use == 2">未使用</span>
                  <span v-if="popupcouponx.is_use == 3">已使用</span>
                </el-form-item>
              </el-col>

              <el-col :span="10">
                <el-form-item label="卡券面值:">
                  <span>{{
                  popupcouponx.quota ? popupcouponx.quota : "-"
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="领取时间:">
                  <span>{{
                  popupcouponx.created_at ? popupcouponx.created_at : "-"
                }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="15">
                <el-form-item label="最低使用额度:">
                  <span>{{
                  popupcouponx.doorsill_price ? popupcouponx.doorsill_price : "-"
                }}</span>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
      </el-scrollbar>
    </el-drawer>
  </div>
</template>

<script>
  import {
    getUserList,
    addUser,
    getgradeList,
    getgroupList,
    getUserDetail,
    editBalance,
    editPoints,
    getTagCategoryAll,
    editUserDetail,
    getBalanceList,
    getVoucherList,
    getIntegralList,
    getInvitationList,
    getRegionList,
    delPoints,
    editCoupon,
  } from "@/api/user/index";
  import {
    QueryCouponList,
    AdminGrantCoupon,
    getCouponUserList
  } from "@/api/coupon/index";
  import LogoUpload from "@/components/FileUpload";
  import deviceLists from "./components/devicelist";
  const tableTheadOption = {
    id: {
      label: "ID",
      field: "id",
    },
    avatar:{
      label: "用户头像",
      field: "avatar",
    },
    nickname: {
      label: "用户昵称",
      field: "nickname",
    },
    mobile: {
      label: "手机号",
      field: "mobile",
    },
    level_name: {
      label: "用户等级",
      field: "level_name",
    },
    source_name: {
      label: "用户来源",
      field: "source_name",
    },
    available_balance: {
      label: "余额",
      field: "available_balance",
    },
    created_at: {
      label: "创建时间",
      field: "created_at",
    },
  };

  const allTableThead = [
    "id",
    "avatar",
    "nickname",
    "mobile",
    "level_name",
    "source_name",
    "available_balance",
    "created_at",
  ];
  const defaultTableThead = [
    "id",
    "avatar",
    "nickname",
    "level_name",
  ];
  export default {
    components: {
      LogoUpload,
      deviceLists
    },
    name: "Orderlist",
    watch: {
      checkboxTableThead(valArr) {
        this.tableThead = this.allTableThead.filter(
          (i) => valArr.indexOf(i) >= 0
        );
        this.tableKey = this.tableKey + 1;
      },
    },
    data() {
      return {
        popupcoupondetails: false, //优惠券明细弹窗
        popupcouponx: {}, //优惠券明细详情
        hiddencoupon:false,
        open_coupondetails: false,
        popupvouerdetails: false,
        popuvouer: {},
        open_vourderdetails: false,
        hiddenvourder: false, //提货券展开
        popuppointx: {},
        popuppointdetails: false, //余额明细弹窗
        open_pointdetails: false,
        hiddenpoint: false, //积分明细展开
        popupbalancex: {}, //余额明细详情
        popupbalancedetails: false, //余额明细弹窗
        hiddenbalance: false, //余额明细窗
        open_balancedetails: false,
        dialogLabel: false,
        audit_type: "2", //审核类型
        // 默认表头
        tableTheadOptions: tableTheadOption,
        allTableThead: allTableThead,
        tableThead: defaultTableThead, // 默认表头
        checkboxTableThead: defaultTableThead, // 默认表头值
        // 为了保证table 每次都会重渲
        tableKey: 1,
        // 搜索选择等级
        gradeList: [],
        // 搜索选择分组
        groupList: [],
        // 搜索选择标签
        TagCategoryAll: [],
        // 用户列表加载框
        loading: false,
        // 用户列表
        userList: [],
        // 用户列表总条数
        total: 0,
        // 当前搜索是否展开
        searchDisplay: false,
        //列表当前选中的数组
        multipleSelection: [],
        // 搜索参数
        searchForm: {
          search_type: 1,
          search_name: "",
          level_id: "",
          group_id: "",
          identity_type: "",
          is_pay: "",
          age: "",
          gender: "",
          is_real_name: "",
          is_consume: "",
          is_new_user: "",
          page: 1,
          count: 10,
        },

        // 页面类型切换 用户类型 0全部 1app 2平台
        customerType: "",
        // 添加修改用户弹框标题
        title: "添加",
        // 修改提交按钮加载
        addPutLoading: false,
        // 添加修改用户弹框是否显示
        userVisible: false,
        // 添加用户头像回显
        avatarFile: {},
        // 添加用户分组回显
        group_id: [],
        // 添加用户等级回显
        level_id: [],
        // 添加用户标签回显
        user_tag_id: [],
        // 省列表
        economizeList: [],
        // 市列表
        cityList: [],
        // 区列表
        countyList: [],
        // 添加用户提交参数
        ruleForm: {
          nickname: "",
          mobile: "",
          gender: "0",
          age: "",
          region: "",
          birthday: "",
          email: "",
          password: "",
          confirm_password: "",
          pay_password: "",
          confirm_pay_password: "",
          level_id: "",
          group_id: "",
          user_tag_id: "",
          avatar: "",
          status: 1,
        },
        // 详情是否显示
        drawer: false,
        // 详情页面加载
        subLoading: false,
        // 用户详情丽taba切换
        activeNames: "基本信息",
        // 用户详情
        userInfoForm: {},
        // 用户详情是否处于编辑状态
        editingStatus: false,
        // 用户详情登录密码回显
        infoPass: "",
        // 用户详情登录密码确认密码
        confirmpwd: "",
        // 用户详情支付密码回显
        infoPayPass: "",
        // 用户详情登录支付密码确认密码
        confirmPaypwd: "",
        // 修改积分余额弹框控制器
        deductionGiftDialog: false,
        // 修改积分余额参数
        modifyForm: {
          modify: "1",
          type: 1,
          balance: 0,
          points: 0,
          remark: "",
        },
        // 消费记录列表
        BalanceList: [],
        CouponUserList:[],//优惠券列表
        totalBalance: 0,
        totalcoupon:0,
        // 消费记录列表搜索参数
        BalanceSearch: {
          user_id: "",
          type: "",
          link_type: "",
          start_time: "",
          end_time: "",
          page: 1,
          count: 10,
        },
        searchcouponForm:{
          coupon_type:'',
          is_use:'',
          user_id: "",
          page: 1,
          count: 10,
          start_time: "",
          end_time: "",
        },
        VoucherList: [],
        totalVoucher: 0,
        VoucherSearch: {
          user_id: "",
          type: "",
          link_type: "",
          start_time: "",
          end_time: "",
          page: 1,
          count: 10,
        },
        IntegralList: [],
        totalIntegral: 0,
        IntegralSearch: {
          user_id: "",
          type: "",
          link_type: "",
          start_time: "",
          end_time: "",
          page: 1,
          count: 10,
        },
        InvitationList: [],
        totalInvitation: 0,
        InvitationSearch: {
          user_id: "",
          page: 1,
          count: 10,
        },
        // 登录设备列表
        deviceList: [],
        totaldevice: 0,
        // 选择的时间数组
        balanceTime: [],
        couponTime: [],
        VoucherTime: [],
        IntegralTime: [],
        // 快捷选择时间的配置
        pickerOptions: {
          shortcuts: [{
              text: "今年至今",
              onClick(picker) {
                const end = new Date();
                const start = new Date(new Date().getFullYear(), 0);
                picker.$emit("pick", [start, end]);
              },
            },
            {
              text: "最近六个月",
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setMonth(start.getMonth() - 6);
                picker.$emit("pick", [start, end]);
              },
            },
          ],
        },

        // 批量设置弹框控制器
        setUpVisible: false,
        // 添加用户表单验证
        rules: {
          nickname: [{
            required: true,
            validator: (rule, value, callback) => {
              if (!value) {
                return callback(new Error("请输入1-10个字符的昵称"));
              }
              callback();
            },
            trigger: "change",
          }, ],
          mobile: [{
            required: true,
            validator: (rule, value, callback) => {
              var reg = /^1[3456789]\d{9}$/;
              if (!reg.test(value)) {
                return callback(new Error("手机号格式不正确"));
              }
              callback();
            },
            trigger: "change",
          }, ],
          age: [{
            required: false,
            validator: (rule, value, callback) => {
              if (value) {
                if (value == 0) {
                  return callback(new Error("请输入真实年龄"));
                } else if (value >= 150) {
                  return callback(new Error("请输入真实年龄"));
                } else {
                  callback();
                }
              } else {
                callback();
              }
            },
            trigger: "blur",
          }, ],
          email: [{
            required: false,
            validator: (rule, value, callback) => {
              if (!value) {
                return callback();
              }
              if (
                /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/.test(value) ==
                false
              ) {
                callback(new Error("邮箱格式不正确"));
              } else {
                callback();
              }
            },
            trigger: "blur",
          }, ],
          password: [{
            required: true,
            validator: (rule, value, callback) => {
              if (
                /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,16}$/.test(value) ==
                false
              ) {
                return callback(
                  new Error("必须包含大小字母和数字,且长度在8-16位之间")
                );
              }
              callback();
            },
            trigger: "change",
          }, ],
          confirm_password: [{
            required: true,
            validator: (rule, value, callback) => {
              if (value === "") {
                callback(new Error("请再次输入密码"));
              } else if (value !== this.ruleForm.password) {
                callback(new Error("两次输入密码不一致!"));
              } else {
                callback();
              }
            },
            trigger: "change",
          }, ],
          pay_password: [{
            required: false,
            validator: (rule, value, callback) => {
              if (!value) {
                return callback();
              }
              if (/^[0-9]{6}$/.test(value) == false) {
                return callback(new Error("请输入6位支付密码"));
              } else {
                if (this.check_pwd(value)) {
                  return callback(new Error("支付密码不能太简单"));
                }
              }
              callback();
            },
            trigger: "blur",
          }, ],
          confirm_pay_password: [{
            required: false,
            validator: (rule, value, callback) => {
              if (this.ruleForm.pay_password) {
                if (value === "") {
                  callback(new Error("请再次输入密码"));
                } else if (value !== this.ruleForm.pay_password) {
                  callback(new Error("两次输入密码不一致!"));
                } else {
                  callback();
                }
              } else {
                callback();
              }
            },
            trigger: "blur",
          }, ],
          avatar: [{
            required: true,
            validator: (rule, value, callback) => {
              if (!value) {
                return callback(new Error("请上传用户头像"));
              }
              callback();
            },
            trigger: "blur",
          }, ],
        },
        // 修改余额积分校验
        modifyrules: {
          points: [{
            required: true,
            validator: (rule, value, callback) => {
              if (value <= 0) {
                return callback(new Error("数量不能小于0"));
              }
              callback();
            },
            trigger: "blur",
          }, ],
        },
        // 修改余额积分校验
        modifyruless: {
          balance: [{
            required: true,
            validator: (rule, value, callback) => {
              if (value <= 0) {
                return callback(new Error("数量不能小于0"));
              }
              callback();
            },
            trigger: "blur",
          }, ],
        },
        // 用户详情修改表单验证
        inforules: {
          nickname: [{
            required: true,
            validator: (rule, value, callback) => {
              if (!value) {
                return callback(new Error("请输入昵称"));
              }
              callback();
            },
            trigger: "blur",
          }, ],
          mobile: [{
            required: true,
            validator: (rule, value, callback) => {
              var reg = /^1[3456789]\d{9}$/;
              if (!reg.test(value)) {
                return callback(new Error("手机号格式不正确"));
              }
              callback();
            },
            trigger: "change",
          }, ],
          age: [{
            required: false,
            validator: (rule, value, callback) => {
              if (value) {
                if (value == 0) {
                  return callback(new Error("请输入真实年龄"));
                } else if (value >= 150) {
                  return callback(new Error("请输入真实年龄"));
                } else {
                  callback();
                }
              } else {
                callback();
              }
            },
            trigger: "blur",
          }, ],
          email: [{
            required: false,
            validator: (rule, value, callback) => {
              if (!value) {
                return callback();
              }
              if (
                /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/.test(value) ==
                false
              ) {
                callback(new Error("邮箱格式不正确"));
              } else {
                callback();
              }
            },
            trigger: "blur",
          }, ],
          password: [{
            required: false,
            validator: (rule, value, callback) => {
              if (!this.infoPass) {
                return callback();
              }
              if (
                /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,16}$/.test(
                  this.infoPass
                ) == false
              ) {
                return callback(
                  new Error("必须包含大小字母和数字,且长度在8-16位之间")
                );
              }
              callback();
            },
            trigger: "change",
          }, ],
          confirm_password: [{
            required: false,
            validator: (rule, value, callback) => {
              if (this.infoPass) {
                if (this.confirmpwd === "") {
                  callback(new Error("请再次输入密码"));
                } else if (this.confirmpwd !== this.infoPass) {
                  callback(new Error("两次输入密码不一致!"));
                } else {
                  callback();
                }
              } else {
                callback();
              }
            },
            trigger: "change",
          }, ],
          pay_password: [{
            required: false,
            validator: (rule, value, callback) => {
              if (!this.infoPayPass) {
                return callback();
              }
              if (/^[0-9]{6}$/.test(this.infoPayPass) == false) {
                return callback(new Error("请输入6位支付密码"));
              } else {
                if (this.check_pwd(this.infoPayPass)) {
                  return callback(new Error("支付密码不能太简单"));
                }
              }
              callback();
            },
            trigger: "change",
          }, ],
          confirm_pay_password: [{
            required: false,
            validator: (rule, value, callback) => {
              if (this.infoPayPass) {
                if (this.confirmPaypwd === "") {
                  callback(new Error("请再次输入密码"));
                } else if (this.confirmPaypwd !== this.infoPayPass) {
                  callback(new Error("两次输入密码不一致!"));
                } else {
                  callback();
                }
              } else {
                callback();
              }
            },
            trigger: "change",
          }, ],
        },
        formData: {},
        // 发送优惠券弹框控制器
        couponsDialogVisible: false,
        couponsLoading: false,
        couponLoading:false,
        couponsList: [],
        couponTotal: 0,
        searchCoupon: {
          page: 1,
          count: 10,
          CouponName: "",
          type: "",
          get_way: "2",
        },
        couponForm: {
          couponId: "",
          type: 2,
          userId: "",
          admin_remark: "",
        },
        sendingDialogVisible: false,
        fsyhjLoading: false,
        editCouponForm: {
          id: "",
          type: 1,
          coupon: "",
          remark: "",
        },
        editCouponDialog: false,
        editCouponLoading: false,
        editCouponRules: {
          type: [{
            required: true,
            validator: (rule, value, callback) => {
              if (value === "") {
                return callback(new Error("请选择修改类型"));
              }
              callback();
            },
            trigger: "change",
          }, ],
          coupon: [{
            required: true,
            validator: (rule, value, callback) => {
              let req = /^\d+(\.\d{1,2})?$/;
              if (req.test(value)) {
                if (Number(value) > 99999999) {
                  return callback(new Error("不能大于99999999"));
                }
                callback();
              } else {
                callback(new Error("最多只能保留两位小数"));
              }
            },
            trigger: "change",
          }, ],
        },
      };
    },
    mounted() {

      getgradeList().then((res) => {
        this.gradeList = res.data.list;
      });
      getgroupList().then((res) => {
        this.groupList = res.data.list;
      });
      getTagCategoryAll().then((res) => {
        this.TagCategoryAll = res.data;
      });
      this.getRegionListWay();
      this.getListWay();
    },
    methods: {
      //审核记录
      audit_records(){

      },
      //关闭提货券记录
      closing_vourder_details() {
        this.open_vourderdetails = false
      },
      closing_point_details() {
        this.open_pointdetails = false
      },
      closing_balance_details() {
        this.open_balancedetails = false
      },
      //关闭优惠券记录
      closing_coupon_details() {
        this.open_coupondetails = false
      },
      //实名变更记录
      CloseDialogLabel() {
        this.dialogLabel = false;

      },
      //实名变更记录
      change_record() {
        this.dialogLabel = true;
      },
      //余额明细
      balance_details() {
        this.open_balancedetails = true
      },
      //积分明细
      integral_details() {
        this.open_pointdetails = true
      },
      //提货券明细
      delivery_voucher_details() {
        this.open_vourderdetails = true
      },
      //卡券明细
      coupons_details() {
        this.open_coupondetails = true
        this.getListcoupon()
      },
      resettingcoupon() {
        this.searchcouponForm = {
          coupon_type:'',
          is_use:'',
          user_id: "",
          start_time: "",
          end_time: "",
          page: 1,
          count: 10,
        };
        this.couponTime = [];
        this.getListcoupon();
      },
      //优惠券列表
      getListcoupon() {
        var objx = this.searchcouponForm;
        objx.user_id = this.userInfoForm.id
        if (this.couponTime.length !== 0) {
          objx.start_time = this.couponTime[0];
          objx.end_time = this.couponTime[1];
        }
        this.couponLoading = true
        getCouponUserList(objx)
          .then((res) => {
            this.couponLoading = false
            this.CouponUserList = res.data.list;
            this.totalcoupon = res.data.total;
          })
          .catch((err) => {
            this.couponLoading = false
            this.$messages.error(err.msg);
          });
      },
      refresh() {
        this.getListWay();
      },
      getRegionListWay() {
        if (localStorage.getItem("region")) {
          let regions = JSON.parse(localStorage.getItem("region"));
          this.economizeList = regions;
        }else{
          getRegionList().then((res) => {
            this.economizeList = res.data;
          });
        }

      },
      // 根据选择的省份获取城市列表
      provinceWay(val) {
        this.ruleForm.city_id = "";
        this.ruleForm.county_id = "";
        this.cityList = [];
        this.countyList = [];
        if (this.userInfoForm.id) {
          this.userInfoForm.city_id = "";
          this.userInfoForm.county_id = "";
        }
        this.economizeList.forEach((res) => {
          if (val == res.id) {
            this.cityList = res.children;
          }
        });
      },
      // 选择区县
      countyWay(val) {
        this.ruleForm.county_id = val;
        if (this.userInfoForm.id) {
          this.userInfoForm.county_id = val;
        }
        this.$forceUpdate();
      },
      // 根据选择的城市获取区县
      cityWay(val) {
        this.ruleForm.county_id = "";
        this.countyList = [];
        if (this.userInfoForm.id) {
          this.userInfoForm.county_id = "";
        }
        this.cityList.forEach((res) => {
          if (val == res.id) {
            this.countyList = res.children;
          }
        });
      },
      // 获取用户列表
      getListWay() {
        this.loading = true;
        var obj = JSON.parse(JSON.stringify(this.searchForm));
        if (obj.user_tag_id instanceof Array) {
          obj.user_tag_id = obj.user_tag_id.join(",");
        }
        getUserList(obj).then((res) => {
          this.loading = false;
          if (res.code !== 200) {
            this.$messages.error(res.msg);
            return;
          }
          this.userList = res.data.list;
          this.total = res.data.total;
        });
      },
      resetting() {
        this.searchForm = {
          search_type: 1,
          search_name: "",
          level_id: "",
          group_id: "",
          identity_type: "",
          is_pay: "",
          age: "",
          gender: "",
          is_real_name: "",
          is_consume: "",
          is_new_user: "",
          page: 1,
          count: 10,
        };
        this.getListWay();
      },
      // 切换用户类型重新获取用户列表
      customerTypeWay() {
        this.searchForm.page = 1;
        this.searchForm.count = 10;
        this.getListWay();
      },
      // 用户列表选择框选中
      handleSelectionChange(val) {
        console.log(val)
        this.multipleSelection = val;
      },
      // 列表中冻结用户
      freezeWay(row) {
        this.$confirm('确定冻结该用户吗, 是否继续?', '', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          var obj = {
            id: row.id,
            status: 0,
          };
          this.loading = true;
          editUserDetail(obj)
            .then((res) => {
              this.loading = false;
              if (res.code !== 200) {
                this.$messages.error(res.msg);
                return;
              } else {
                this.getListWay();
                this.$messages.success("该账户已冻结");
              }
            })
            .catch(() => {
              this.loading = false;
            });
        }).catch(() => {});
      },
      // 用户列表解冻用户
      thawWay(row) {
        this.$confirm('确定重新启用该用户吗, 是否继续?', '', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          var obj = {
            id: row.id,
            status: 1,
          };
          this.loading = true;
          editUserDetail(obj).then((res) => {
            this.loading = false;
            if (res.code !== 200) {
              this.$messages.error(res.msg);
              return;
            } else {
              this.getListWay();
              this.$messages.success("该账户重新已启用");
            }
          });
        }).catch(() => {});
      },
      // 删除用户
      deleteCoupon(row) {
        this.loading = true;
        delPoints({
            id: row.id
          })
          .then((res) => {
            this.loading = false;
            if (res.code !== 200 || res.status !== 1) {
              return this.$messages.error(res.msg);
            }
            this.$messages.success("删除成功");
            this.getListWay();
          })
          .catch((err) => {
            this.loading = false;
            this.$messages.error(err.msg);
          });
      },
      // 添加用户调起弹框
      addUserWay() {
        this.userVisible = true;
        this.title = "添加";
      },
      // 修改用户调起弹框
      putUserWay() {
        this.userVisible = true;
        this.title = "修改";
      },
      // 添加修改弹框关闭
      userHandleClose() {
        this.avatarFile = {};
        this.userVisible = false;
        this.avatarFile = {};
        this.ruleForm = {
          nickname: "",
          mobile: "",
          gender: "0",
          age: "",
          region: "",
          birthday: "",
          email: "",
          password: "",
          confirm_password: "",
          pay_password: "",
          confirm_pay_password: "",
          level_id: "",
          group_id: "",
          user_tag_id: "",
          avatar: "",
          status: 1,
        };
        this.$refs.ruleForm.resetFields();
      },
      // 添加用户选择用户标签触发
      ruleFormUsertagid(val) {
        this.ruleForm.user_tag_id = val.toString();
      },
      // 添加修改表单提交
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.addPutLoading = true;
            var obj = {};
            for (var key in this.ruleForm) {
              if (this.ruleForm[key]) {
                obj[key] = this.ruleForm[key];
              }
            }
            addUser(obj)
              .then((res) => {
                this.addPutLoading = false;
                if (res.code !== 200) {
                  this.$messages.error(res.msg);
                  return;
                }
                this.$refs[formName].resetFields();
                this.getListWay();
                this.userVisible = false;
              })
              .catch(() => {
                this.addPutLoading = false;
              });
          } else {
            return this.$messages.warning("有必填项未填写");
          }
        });
      },
      //关闭提货券明细详情
      popup_vouer_details() {
        this.popupvouerdetails = false
      },
      //关闭积分明细详情
      popup_point_details() {
        this.popuppointdetails = false
      },
      //关闭余额明细详情
      popup_balance_details() {
        this.popupbalancedetails = false
      },
      //查看余额明细详情
      popupbalances(row) {
        this.popupbalancedetails = true
        this.popupbalancex = row
      },
      //关闭优惠券明细详情
      popup_coupon_details() {
        this.popupcoupondetails = false
      },
      //查看优惠券明细详情
      popupcoupon(row) {
        this.popupcoupondetails = true
        this.popupcouponx = row
      },
      //查看积分明细详情
      popuppoints(row) {
        this.popuppointdetails = true
        this.popuppointx = row
      },
      //查看提货券明细详情
      popupvoures(row) {
        this.popupvouerdetails = true
        this.popuvouer = row
      },
      //查看用户详情
      drawerHandle(row) {
        this.infoPass = ''
        this.confirmpwd = ''
        this.drawer = true;
        this.subLoading = true;
        this.activeNames = "基本信息"
        getUserDetail({
          id: row.id
        }).then((res) => {
          res.data.gender = res.data.gender == 0 ? "" : res.data.gender + "";
          this.userInfoForm = res.data;
          this.userInfoForm.province_id =
            this.userInfoForm.province_id == 0 ?
            "" :
            this.userInfoForm.province_id;
          this.userInfoForm.city_id =
            this.userInfoForm.city_id == 0 ? "" : this.userInfoForm.city_id;
          this.userInfoForm.county_id =
            this.userInfoForm.county_id == 0 ? "" : this.userInfoForm.county_id;
          this.userInfoForm.level_id =
            this.userInfoForm.level_id == 0 ? "" : this.userInfoForm.level_id;
          this.userInfoForm.group_id =
            this.userInfoForm.group_id == 0 ? "" : this.userInfoForm.group_id;
          this.userInfoForm.county_id =
            this.userInfoForm.county_id == 0 ? "" : this.userInfoForm.county_id;
          if (res.data.user_tag_id) {
            var arr = res.data.user_tag_id.split(",");
            arr.forEach((item) => {
              this.user_tag_id.push(Number(item));
            });
          } else {
            this.user_tag_id = [];
          }
          this.economizeList.forEach((ress) => {
            if (ress.id == this.userInfoForm.province_id) {
              this.cityList = ress.children;
              this.cityList.forEach((item) => {
                if (item.id == this.userInfoForm.city_id) {
                  this.countyList = item.children;
                }
              });
            }
          });
          this.formData = JSON.parse(JSON.stringify(res.data));
          this.subLoading = false;
        });
      },
      // 用户详情中选择用户标签触发
      userInfoFormUsertagid(val) {
        this.userInfoForm.user_tag_id = val.toString();
      },
      // 计算详情中的年龄
      userInfobirthdayWay(val) {
        this.userInfoForm.age = getAge(val);

        function getAge(val) {
          let currentYear = new Date().getFullYear(); //当前的年份
          let calculationYear = new Date(val).getFullYear(); //计算的年份
          const wholeTime = currentYear + val.substring(4); //周岁时间
          const calculationAge = currentYear - calculationYear; //按照年份计算的年龄
          //判断是否过了生日
          if (new Date().getTime() > new Date(wholeTime).getTime()) {
            return calculationAge;
          } else {
            return calculationAge - 1;
          }
        }
      },
      saveUserInfoWay() {
        if (!this.editingStatus) {
          this.editingStatus = true;
          this.activeNames = "基本信息";
        } else {
          this.$refs.inforules.validate((valid) => {
            if (valid) {
              if (this.infoPass) {
                this.userInfoForm.password = this.infoPass;
                this.userInfoForm.confirm_password = this.confirmpwd;
              } else {
                this.userInfoForm.password = "";
                this.userInfoForm.confirm_password = "";
              }
              if (this.infoPayPass) {
                this.userInfoForm.pay_password = this.infoPayPass;
                this.userInfoForm.confirm_pay_password = this.confirmPaypwd;
              } else {
                this.userInfoForm.pay_password = "";
                this.userInfoForm.confirm_pay_password = "";
              }
              this.subLoading = true;
              var obj = {};
              for (var key in this.userInfoForm) {
                if (this.formData[key] !== this.userInfoForm[key]) {
                  if (
                    this.userInfoForm[key].constructor !== Object &&
                    this.userInfoForm[key].constructor !== Array
                  ) {
                    if (
                      key !== "confirm_password" ||
                      key !== "confirm_pay_password" ||
                      key !== "password"
                    ) {
                      if (this.userInfoForm[key] !== "") {
                        obj[key] = this.userInfoForm[key];
                      }
                    } else {
                      obj[key] = this.userInfoForm[key];
                    }
                  }
                }
              }
              obj.id = this.userInfoForm.id;
              editUserDetail(obj)
                .then((res) => {
                  this.subLoading = false;
                  if (res.code !== 200) {
                    this.$messages.error(res.msg);
                    return;
                  }
                  this.$messages.success("修改成功!");
                  this.user_tag_id = [];
                  this.editingStatus = false;
                  this.drawerHandle(this.userInfoForm);
                  this.getListWay();
                })
                .catch(() => {
                  this.editingStatus = false;
                });
            } else {
              return false;
            }
          });
        }
      },
      // 关闭详情框
      drawerHandleClose() {
        this.userInfoForm = {};
        this.user_tag_id = [];
        this.drawer = false;
        this.editingStatus = false;
      },
      // 详情中打开赠送积分余额的弹框
      deductionGift() {
        this.deductionGiftDialog = true;
        this.modifyForm.modify = 1
        this.modifytabsClick();
      },
      deductionGiftpoint() {
        this.deductionGiftDialog = true;
        this.modifyForm.modify = 2
        this.modifytabsClick();
      },
      // 详情中关闭修改积分余额弹框
      deductionhandleClose() {
        this.modifyForm = {
          modify: "1",
          type: 1,
          balance: 0,
          points: 0,
          remark: "",
        };
        this.deductionGiftDialog = false;
      },
      // 详情中打开修改提券
      editCouponWay() {
        this.editCouponClose();
        this.editCouponForm.id = this.userInfoForm.id;
        this.editCouponDialog = true;
      },
      editCouponClose() {
        this.editCouponDialog = false;
        this.editCouponForm = {
          id: "",
          type: 1,
          coupon: "",
          remark: "",
        };
      },
      submiteditCoupon(name) {
        this.$refs[name].validate((valid) => {
          if (valid) {
            this.editCouponLoading = true;
            editCoupon(this.editCouponForm).then((res) => {
              this.editCouponLoading = false;
              if (res.code !== 200) {
                this.$messages.error(res.msg);
                return;
              }
              this.$messages.success(res.msg);
              this.editCouponClose();
              this.getVoucherListWay();
            });
          } else {
            return false;
          }
        });
      },
      // 详情中切换积分修改
      modifytabsClick(formName) {
        if (this.modifyForm.modify == 2) {
          this.$refs.modifyrules.resetFields();
        } else {
          this.$refs.modifyruless.resetFields();
        }
      },
      // 提交积分余额修改
      submitdeductionGift() {
        if (this.modifyForm.modify == 2) {
          this.$refs.modifyrules.validate((valid) => {
            if (valid) {
              var obj = {
                id: this.userInfoForm.id,
                ...this.modifyForm,
              };
              var Obj1 = {
                id: this.userInfoForm.id,
              };
              if (this.modifyForm.modify == 1) {
                Obj1 = {
                  id: this.userInfoForm.id,
                  type: this.modifyForm.type,
                  balance: this.modifyForm.balance,
                  remark: this.modifyForm.remark,
                };
              } else {
                Obj1 = {
                  id: this.userInfoForm.id,
                  type: this.modifyForm.type,
                  points: this.modifyForm.points,
                  remark: this.modifyForm.remark,
                };
              }
              editPoints(Obj1).then((res) => {
                if (res.code !== 200) {
                  this.$messages.error(res.msg);
                  return;
                }
                this.$messages.success("操作成功!");
                this.drawerHandle(this.userInfoForm);
                this.deductionhandleClose();

                this.getIntegralListWay();
              });
            }
          });
        } else {
          this.$refs.modifyruless.validate((valid) => {
            if (valid) {
              var obj = {
                id: this.userInfoForm.id,
                ...this.modifyForm,
              };
              editBalance(obj).then((res) => {
                if (res.code !== 200) {
                  this.$messages.error(res.msg);
                  return;
                }
                this.$messages.success("操作成功!");
                this.drawerHandle(this.userInfoForm);
                this.deductionhandleClose();
                this.getBalanceListWay();
              });
            }
          });
        }
      },
      //详情中切换订单类型
      infotabshandleClick(tab) {
        if (this.activeNames == "基本信息") {
          // this.drawerHandle(this.userInfoForm);
        } else if (this.activeNames == "财产信息") {
          this.getBalanceListWay();
          this.getIntegralListWay();
          this.getVoucherListWay();
        } else if (this.activeNames == "提货券记录") {
          this.getVoucherListWay();
        } else if (this.activeNames == "积分记录") {
          this.getIntegralListWay();
        } else if (this.activeNames == "推荐人变更记录") {
          this.getInvitationListWay();
        } else if (this.activeNames == "使用设备列表") {
          setTimeout(()=>{
            this.$refs.refInventory.getdeviceListWays(this.userInfoForm.id)
          },800)
        }
      },
      resettingBalance() {
        this.BalanceSearch = {
          user_id: this.userInfoForm.id,
          type: "",
          link_type: "",
          start_time: "",
          end_time: "",
          page: 1,
          count: 10,
        };
        this.balanceTime = [];
        this.getBalanceListWay();
      },
      getBalanceListWay() {
        var obj = this.BalanceSearch;
        obj.user_id = this.userInfoForm.id;
        if (this.balanceTime && this.balanceTime.length !== 0) {
          obj.start_time = this.balanceTime[0];
          obj.end_time = this.balanceTime[1];
        }else{
          obj.start_time = ''
          obj.end_time = ''
        }
        this.subLoading = true;
        getBalanceList(obj)
          .then((res) => {
            this.subLoading = false;
            if (res.code !== 200) {
              this.$messages.error(res.msg);
              return;
            }
            this.BalanceList = res.data.list;
            this.totalBalance = res.data.total;
          })
          .catch(() => {
            this.subLoading = false;
          });
      },
      // 分页选择调用
      handleBalanceSizeChange(val) {
        this.BalanceSearch.count = val;
        this.getBalanceListWay();
      },
      // 分页选择调用
      handleBalanceCurrentChange(val) {
        this.BalanceSearch.page = val;
        this.getBalanceListWay();
      },
      // 优惠券分页选择调用
      handlecouponSizeChange(val) {
        this.searchcouponForm.count = val;
        this.getListcoupon();
      },
      // 优惠券分页选择调用
      handlecouponCurrentChange(val) {
        this.searchcouponForm.page = val;
        this.getListcoupon();
      },
      // 详情提货券重置
      resettingVoucher() {
        this.VoucherSearch = {
          user_id: this.userInfoForm.id,
          type: "",
          link_type: "",
          start_time: "",
          end_time: "",
          page: 1,
          count: 10,
        };
        this.VoucherTime = [];
        this.getVoucherListWay();
      },
      // 获取提货券列表
      getVoucherListWay() {
        var obj = this.VoucherSearch;
        obj.user_id = this.userInfoForm.id;
        if (this.VoucherTime && this.VoucherTime.length !== 0) {
          obj.start_time = this.VoucherTime[0];
          obj.end_time = this.VoucherTime[1];
        }else{
          obj.start_time = ''
          obj.end_time = ''
        }
        this.subLoading = true;
        getVoucherList(obj)
          .then((res) => {
            this.subLoading = false;
            if (res.code !== 200) {
              this.$messages.error(res.msg);
              return;
            }
            this.VoucherList = res.data.list;
            this.totalVoucher = res.data.total;
          })
          .catch(() => {
            this.subLoading = false;
          });
      },
      // 分页选择调用
      handleVoucherCurrentChange(val) {
        this.VoucherSearch.page = val;
        this.getVoucherListWay();
      },
      // 分页选择调用
      handleVoucherSizeChange(val) {
        this.VoucherSearch.count = val;
        this.getVoucherListWay();
      },
      // 详情积分重置
      resettingIntegral() {
        this.IntegralSearch = {
          user_id: this.userInfoForm.id,
          type: "",
          link_type: "",
          start_time: "",
          end_time: "",
          page: 1,
          count: 10,
        };
        this.IntegralTime = [];
        this.getIntegralListWay();
      },
      // 获取积分列表
      getIntegralListWay() {
        var obj = this.IntegralSearch;
        obj.user_id = this.userInfoForm.id;
        if (this.IntegralTime && this.IntegralTime.length !== 0) {
          obj.start_time = this.IntegralTime[0];
          obj.end_time = this.IntegralTime[1];
        }else{
          obj.start_time = ''
          obj.end_time = ''
        }
        this.subLoading = true;
        getIntegralList(obj)
          .then((res) => {
            this.subLoading = false;
            if (res.code !== 200) {
              this.$messages.error(res.msg);
              return;
            }
            this.IntegralList = res.data.list;
            this.totalIntegral = res.data.total;
          })
          .catch(() => {
            this.subLoading = false;
          });
      },
      // 分页选择调用
      handleIntegralCurrentChange(val) {
        this.IntegralSearch.page = val;
        this.getIntegralListWay();
      },
      // 分页选择调用
      handleIntegralSizeChange(val) {
        this.IntegralSearch.count = val;
        this.getIntegralListWay();
      },
      // 获取邀请人列表
      getInvitationListWay() {
        var obj = this.InvitationSearch;
        obj.user_id = this.userInfoForm.id;
        this.subLoading = true;
        getInvitationList(obj)
          .then((res) => {
            this.subLoading = false;
            if (res.code !== 200) {
              this.$messages.error(res.msg);
              return;
            }
            this.InvitationList = res.data.list;
            this.totalInvitation = res.data.total;
          })
          .catch(() => {
            this.subLoading = false;
          });
      },
      // 分页选择调用
      handleInvitationCurrentChange(val) {
        this.InvitationSearch.count = val;
        this.getInvitationListWay();
      },
      // 分页选择调用
      handleInvitationSizeChange(val) {
        this.InvitationSearch.page = val;
        this.getInvitationListWay();
      },
      //单人发放优惠券
      single_sendCouponsWay(row){
        let obj = [
          {
            id:row.id
          }
        ]
        this.multipleSelection = obj
          this.getCouponListWay();
          this.couponsDialogVisible = true;
      },
      // 发送优惠券按钮
      sendCouponsWay() {
        if (this.verifyWay()) {
          this.getCouponListWay();
          this.couponsDialogVisible = true;
        }
      },
      // 发送优惠券弹框中使用 获取优惠券列表
      getCouponListWay() {
        this.couponsLoading = true;
        QueryCouponList(this.searchCoupon)
          .then((res) => {
            this.couponsLoading = false;
            this.couponsList = res.data.list;

          })
          .catch((err) => {
            this.$messages.error(err.msg);
            this.couponsLoading = false;
          });
      },
      // 发送优惠券
      sendingWay(row) {
        this.couponForm.couponId = row.id;
        this.sendingDialogVisible = true;
      },
      sendingsHandleClose() {
        this.couponForm = {
          couponId: "",
          type: 2,
          userId: "",
          admin_remark: "",
        };
        this.sendingDialogVisible = false;
      },
      faosngyouhuiquan() {
        this.fsyhjLoading = true;
        var arr = [];
        this.multipleSelection.forEach((item) => {
          arr.push(item.id);
        });
        this.couponForm.userId = arr.toString();
        setTimeout(() => {
          AdminGrantCoupon(this.couponForm)
            .then((res) => {
              this.fsyhjLoading = false;
              if (res.code !== 200 || res.status !== 1) {
                return this.$messages.error(res.msg);
              }
              this.fsyhjLoading = false;
              this.sendingDialogVisible = false;
              this.$messages.success(res.msg);
            })
            .catch((res) => {
              this.$messages.error(res.msg);
              this.fsyhjLoading = false;
            });

          console.log(this.couponForm);
        }, 300);
      },
      CouponSizeChange(val) {
        this.searchCoupon.count = val;
        this.getCouponListWay();
      },
      CouponCurrentChange(val) {
        this.searchCoupon.page = val;
        this.getCouponListWay();
      },
      // 关闭优惠券弹框
      couponsHandleClose() {
        this.couponsDialogVisible = false;
      },
      // 批量设置标签按钮
      setUpWay() {
        if (this.verifyWay()) {
          console.log("该弹框了");
        }
      },
      // 分页选择调用
      handleSizeChange(val) {
        this.searchForm.count = val;
        this.getListWay();
      },
      // 分页选择调用
      handleCurrentChange(val) {
        this.searchForm.page = val;
        this.getListWay();
      },
      // 上传头像调用
      avatarCallback(singleFile) {
        this.avatarFile = singleFile;
        this.ruleForm.avatar = singleFile.url;
      },
      // 验证当前列表是否选择用户
      verifyWay() {
        if (this.multipleSelection.length == 0) {
          this.$messages.warning("请选择用户后操作");
          return false;
        } else {
          return true;
        }
      },
      // 计算年龄
      birthdayWay(val) {
        this.ruleForm.age = getAge(val);

        function getAge(val) {
          let currentYear = new Date().getFullYear(); //当前的年份
          let calculationYear = new Date(val).getFullYear(); //计算的年份
          const wholeTime = currentYear + val.substring(4); //周岁时间
          const calculationAge = currentYear - calculationYear; //按照年份计算的年龄
          //判断是否过了生日
          if (new Date().getTime() > new Date(wholeTime).getTime()) {
            return calculationAge;
          } else {
            return calculationAge - 1;
          }
        }
      },

      check_pwd(pwd) {
        // 2a(n)=a(n-1)+a(n+1)
        var eq_seq = true;
        for (var i = 1; i < pwd.length - 1; i++) {
          if (
            2 * pwd.charAt(i) !=
            Number(pwd.charAt(i - 1)) + Number(pwd.charAt(i + 1))
          ) {
            eq_seq = false;
          }
        }
        return eq_seq;
      },
    },
  };
</script>

<style lang="scss" scoped>
  img {
    width: 100%;
    height: 100%;
  }

  .title {
    color: rgba(0, 0, 0, 0.85);
    font-weight: 500;
    font-size: 16px;
    line-height: 16px;
  }

  .sn {
    color: #606266;
    font-size: 13px;
  }

  .order_center {
    display: flex;
    align-items: center;
    justify-content: start;
    flex-wrap: wrap;
    padding: 0 2px 0 0;
    font-size: 13px;
    color: #666;
  }

  .infoDiv {
    display: flex;
    // align-items: center;
    background-color: #F5F5F5;
    border-radius: 6px;
    padding: 10px;
    margin-top: 10px;
    margin-bottom: 10px;

    .img {
      width: 65px;
      height: 65px;
      border-radius: 50%;
      background-color: #fff;
    }
    .right{

    }
    .scenter {
      flex: 1;
      margin-left: 10px;

      h3 {
        line-height: 30px;
        font-weight: 400;
        font-size: 16px;
        padding: 0px 0;
        margin: 0;
      }
    }
  }

  .infoDivTop {
    display: flex;

    .img {
      width: 80px;
      height: 80px;
      border-radius: 50%;
      background-color: #000;
    }

    .text {
      line-height: 80px;
      font-weight: 500;
      font-size: 16px;
      color: rgba(0, 0, 0, 0.85);
      margin-left: 20px;
    }

    .right {
      flex: 1;
      text-align: right;
    }
  }

  .orderdetail_item {
    display: flex;
    // width: 165px;
    justify-content: start;
    margin-right: 30px;

    p:nth-child(2) {
      color: #000;
      font-weight: 550;
      margin-left: 15px;
    }
  }

  .blockquote-box {
    color: #606266;
    border-left: 8px solid #409eff;
    padding-left: 14px;
    margin: 6px 0;
    height: 36px;
    line-height: 36px;
    background: #fafafa;
    font-size: 14px;
    font-weight: 550;
  }

  .change_record {
    margin-right: 20px;
    color: #6c6c6c;
    font-weight: 550;
    font-size: 12px;
  }

  .realname {
    margin-right: 20px;
    color: #707722;
    font-weight: 550;
    font-size: 12px;
  }

  .vouber {
    background: #69912b !important;
  }

  .coupons {
    background: #85c8e1 !important;
  }

  .point {
    background: #f4ae57 !important;
  }

  .accumulated_consumption {
    padding: 0 20px 20px;
    border: 1px solid #F5F5F5;
    margin-top: 30px;
    border-radius: 10px;

    .flexas {
      display: flex;
      align-items: center;
    }

    .cash_consumption {
      display: flex;
      align-items: center;
      margin-right: 60px;
      width: 300px;

      .cashimg {
        width: 50px;
        height: 50px;
        background-color: #74b7ff;
        border-radius: 6px;
        margin-right: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
      }

      .accumulated_price {
        font-size: 12px;
        color: #2f2736;
        line-height: 24px;
      }

      .nums {
        font-size: 16px;
        color: #2d90ff;
        line-height: 26px;
        font-weight: 550;
      }
    }

    .banlance {
      font-size: 15px;
      color: #101010;
      line-height: 50px;
      font-weight: 550;
    }
  }

  .balance_information {
    background: #83bfff;
    padding: 14px 20px;
    border-radius: 10px;

    .banlance {
      color: #fff;
      font-size: 14px;
      line-height: 28px;
      font-weight: 550;
    }

    .total {
      color: #fff;
      font-size: 18px;
      line-height: 34px;
      font-weight: 550;
    }

    .num {
      color: #fff;
      font-size: 14px;
      font-weight: 550;
    }

  }

  .reason_for_rejection {
    width: 100%;
    height: 100px;
    background: #f7f8fa;
    border-radius: 6px;
    padding: 10px;
    font-size: 12px;
  }
</style>
<style>
  .input-with-select .el-select .el-input {
    width: 100px !important;
  }
</style>
